Class: MouseTracker

bcdui.widget. MouseTracker

A utility class tracking mouse enter and leave events within a specified parent element. It keeps track of the mouse movement and fires the event as soon as the mouse does not move for a certain amount of time (default 200 ms). This is useful because when the function does a complex computation like executing a tooltip XSLT it is not recommended to execute it with every mouse move.

Please note that "onLeave" does NOT work on HTML table elements in FireFox. So in this case the baseElement must be the DIV containing the table.

Example:

 new bcdui.widget.MouseTracker({
           baseElement: $$("table.treeView")[0].up()
         , delay: 1000
         , onEnter: function(e) {
             bcdui.log.isTraceEnabled() && bcdui.log.trace("row No: " + e.element().rowIndex);
           }
         , onLeave: function() {
             bcdui.log.isTraceEnabled() && bcdui.log.trace("onLeave")
           }
         , filter: "tr"
       }).start();
 

new bcdui.widget.MouseTracker(args)

widget/mouseTracker.js, line 61
Creates a new mouse tracker instance. This instance is inactive until the #start() method is called. Then it tracks the mouse movement on the specified base element until the #stop() method is executed.
Name Type Description
args Object The argument map offers the following properties:
Name Type Description
baseElement HtmlElement | String The id or HTML element that contains the sub-elements the mouse enter / leave events should be tracked on. It is recommended to use an HTML DIV element as base element.
onEnter function optional The function to be executed when an observed element is entered by the mouse pointer. This function gets an event parameter (of the type bcdui.widget.DetachedEvent) as argument.
onLeave function optional A function which is run when the mouse leaves an observed element. The function has no arguments.
filter String optional The tag name (or multiple pipe-separated tag names) that should be observed for the onEnter / onLeave events. It is often TD or TR so that moving the mouse over table cells / rows inside the base element is observed. If omitted every child element is observed.
delay integer optional The duration in milliseconds defining how long the events should be idle until the provided function is triggered. The default value is 200.

Methods

start()

widget/mouseTracker.js, line 142
Starts the observation of the base element. New instances of the MouseTracker object do not automatically start tracking so the start() method should be called on them.

stop()

widget/mouseTracker.js, line 154
Stops observing the base element for mouse enter / leave.