lz.GlobalMouseService
Application-wide control of and information about the mouse.

JavaScript: lz.GlobalMouseService
extends lz.Eventable »

lz.GlobalMouse is the single instance of the class lz.GlobalMouseService.

The lz.GlobalMouse service sends events any time the mouse button state changes, even if mouse events are locked using the lz.ModeManager API. The lz.GlobalMouse is also useful for detecting when the mouse button goes up or down on a non-clickable view.

<canvas height="100">
   <simplelayout inset="10" spacing="10"/>

   <checkbox>Lock mouse events
     <handler name="onvalue">
       if (this.value){
         lz.ModeManager.globalLockMouseEvents();
       }
     </handler>

     <handler name="onclick" reference="lz.GlobalMouse" args="who"><![CDATA[
       //need to use lz.GlobalMouse, since we don't get clicks if we're
       //checked. Note: lz.GlobalMouse sends its events before the view
       //receives the events, so we can just unlock it here, and the
       //checkbox can do its normal onclick handling.
       if (this.value && who == this){
         lz.ModeManager.globalUnlockMouseEvents();
       }
     ]]></handler>
   </checkbox>

   <button>click me!</button>

   <text resize="true">
     <method name="showEvent" args="what, who">
       this.format("%s: %w", what, who);
     </method>

     <handler name="onmouseover" reference="lz.GlobalMouse" args="who">
       this.showEvent("mouseover" , who);
     </handler>
     <handler name="onmouseout" reference="lz.GlobalMouse" args="who">
       this.showEvent("mouseout" , who);
     </handler>

     <handler name="onmousedown" reference="lz.GlobalMouse" args="who">
       this.showEvent("mousedown" , who);
     </handler>
     <handler name="onmouseup" reference="lz.GlobalMouse" args="who">
       this.showEvent("mouseup" , who);
     </handler>

     <handler name="onclick" reference="lz.GlobalMouse" args="who">
       this.showEvent("mouseclick" , who);
     </handler>
   </text>
 </canvas>

Use the lz.GlobalMouse service in conjunction with lz.ModeManager's event lock.

Class Attributes

Name (CSS property) Type (tag) Type (js) Default Category
LzGlobalMouse   lz.GlobalMouseService   readonly
  The global mouse service. Also available as the global lz.GlobalMouse.

Methods

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Name Description
onclick Sent whenever the mouse button is clicked
ondblclick Sent whenever the mouse button is double-clicked
onmousedown Sent whenever the mouse button goes down
onmousedragin Sent whenever the mouse is dragged in to a view
onmousedragout Sent whenever the mouse is dragged out of a view
onmouseenter Sent whenever the mouse is moved over the canvas
onmouseevent Sent for all mouse events
onmouseleave Sent whenever the mouse is moved off the canvas
onmousemove Sent whenever the mouse moves
onmouseout Sent whenever the mouse leaves a view
onmouseover Sent whenever the mouse enters a view
onmouseup Sent whenever the mouse button goes up
onmouseupoutside Sent whenever the mouse button goes up outside the view where it first went down

Events inherited from lz.Eventable

ondestroy