Class DwtOutsideMouseEventMgr
This class is designed to make it easy for a widget to detect mouse events
that happen somewhere outside its HTML structure. The typical use case is
so that a menu can pop down when a user clicks outside of it, but there are
others. For the most part, we care about mousedown events.
There are several ways to detecting outside mouse events:
1. Set the body element to capture all mouse events, using DwtMouseEventCapture.
That is all that's needed for non-IE browsers.
2. Any control that receives an event calls the global listener through
DwtEventManager.
3. The shell listens for mouse events.
4. Listen for window blur events.
2 and 3 are used by IE only. Note that the controls and the shell must be handling
those events in order to trigger the listeners.
4 is not used by IE, since window.onblur does not work correctly on IE. It's possible to
use document.onfocusout, but that is triggered even on clicks within the document, so
you need to check activeElement and cross your fingers. It's not worth the risk.
We also have classes that create elements in another document (IFRAME) forward
their mouse events to us so that we can notify a client object if appropriate.
The one class that does that is DwtIframe.
The framework can support multiple simultaneous clients. For example, a context
menu and toast could both be listening for outside mouse clicks at the same time.
Each will be notified as appropriate. If the toast is clicked, the context menu
will be notified of an outside click.
A client may also add an element to its defined "inside" area by calling
startListening() with the same ID. One use case is a menu that pops up a submenu.
The two are considered together when determining if a mouse click was "outside".
If the submenu pops down, its element is removed from the area to check.
Defined in: DwtOutsideMouseEventMgr.js.
Class Summary
Constructor Attributes |
Constructor Name and Description |
|
Creates a singleton that manages outside mouse clicks for a given widget.
|
Method Summary
Method Attributes |
Method Name and Description |
<static> |
If the event is one we're listening for, check its target to see if
we should pass it along.
|
|
Start listening for outside mouse events on behalf of the given object.
|
|
Stop listening for outside mouse events.
|
Class Detail
DwtOutsideMouseEventMgr()
Creates a singleton that manages outside mouse clicks for a given widget.
Method Detail
<static>
DwtOutsideMouseEventMgr.forwardEvent(ev)
If the event is one we're listening for, check its target to see if
we should pass it along.
- Parameters:
-
{Event} ev
startListening(params)
Start listening for outside mouse events on behalf of the given object.
- Parameters:
-
{hash} params
- hash of params:
-
{string} params.id
- unique ID for this listening session
-
{DwtControl} params.obj
- control on behalf of whom we're listening
-
{string} params.elementId
- ID of reference element, if other than control's HTML element
-
{AjxListener} params.outsideListener
- listener to call when we get an outside mouse event
-
{boolean} params.noWindowBlur
- if true, don't listen for window blur events; useful for dev
stopListening(params)
Stop listening for outside mouse events. Listening is stopped for the element
provided, if any, or for the element indicated by the context ID. Outside
listeners are removed once there are no more elements in the context.
- Parameters:
-
{string|hash} params
- ID, if string, otherwise hash of params:
-
{string} params.id
- unique ID for this listening session
-
{DwtControl} params.obj
- control on behalf of whom we're listening
-
{string} params.elementId
- ID of element to remove from listening context
-
{boolean} params.noWindowBlur
- if true, don't listen for window blur events; useful for dev
|