lz.ModeManagerService
Controls pass-through of mouse events.

JavaScript: lz.ModeManagerService
extends lz.Eventable »

lz.ModeManager is the single instance of the class lz.ModeManagerService.

The mode manager controls the dispatch of mouse events to the rest of the system. The mode manager keeps a stack of modal views. When a view is made modal (with the call lz.ModeManager.makeModal()) only it and its children receive mouse events.

In the example below, the window grabs the mode when it is opened and releases it when it is closed. Note that the button no longer responds to mouse examplesses after the window is made modal, but the children of the window (such as the close button and the drag bar) still do. For a more detailed example of using modes with OpenLaszlo, see modeexample.lzx in the examples directory.

Example 23. Using the mode manager to make a window behave like a modal dialog

<canvas height="160">
   <button name="b1" onclick="winDia.openWindow()">Show modal dialog</button>
   <window width="200" name="winDia" closeable="true" visible="false" x="150" title="modal dialog">
     <method name="openWindow">
       this.open();
       lz.ModeManager.makeModal(this);
     </method>
     <method name="close">
       lz.ModeManager.release(this);
       super.close();
     </method>
   </window>
 </canvas>

Class Attributes

Name (CSS property) Type (tag) Type (js) Default Category
LzModeManager   lz.ModeManagerService   readonly
  The modemanager service. Also available as the global lz.ModeManager.

Methods

globalLockMouseEvents()
lz.ModeManagerService.globalLockMouseEvents();
Prevents all mouse events from firing.

globalUnlockMouseEvents()
lz.ModeManagerService.globalUnlockMouseEvents();
Restore normal mouse event firing.

hasMode()
lz.ModeManagerService.hasMode(view : lz.view);
Tests whether the given view is in the modelist.
Parameter Name Type Description
view lz.view The mode to be tested to see if it is in the modelist
Returns Type Description
  Boolean true if the view is in the modelist

makeModal()
lz.ModeManagerService.makeModal(view : lz.view);
Pushes the view onto the stack of modal views
Parameter Name Type Description
view lz.view The view intending to have modal iteraction

release()
lz.ModeManagerService.release(view : lz.view);
Removes the view (and all the views below it) from the stack of modal views
Parameter Name Type Description
view lz.view The view to be released of modal interaction

releaseAll()
lz.ModeManagerService.releaseAll();
Clears all modal views from the stack

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
onmode Sent when the mode changes.

Events inherited from lz.Eventable

ondestroy