Class EventHandler
 Events may be intercepted at
 the page level using standard GWT methods such as addNativePreviewHandler() on the 
 com.google.gwt.user.client.Event class. 
If the event occurred on an enabled widget it is sent to that widget's event handler, if any. This handler can cancel further propagation of the event by returning false. An "enabled" widget is any widget that defines an event handler for one of the supported events.
 The event is "bubbled"
 up to the widget's parent in the containment hierarchy, if any. Again, the parent's handler for the event can cancel
 further propagation by calling event.cancel(). This step is repeated, with the event "bubbling" up  through
 the containment hierarchy, until a top-level widget is reached or the event is  explicitly canceled. 
Where applicable, canceling an event will also typically suppress the native behavior (for example canceling a keypress while focused in a form item may prevent the key character being inserted in the text box).
SmartGWT libraries will not interfere with native event handling when events occur outside of a target widget. You can therefore have HTML that is not ISC-based on the same page as widget objects that will react to native events as you would expect.
- See Also:
- 
- PageEvent
- com.smartgwt.client.util.Page#setEvent
- com.smartgwt.client.util.Page#clearEvent
 
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic BooleanReturn true if the alt (option) key is being held down.static BooleanReturn true if the control key is being held down.static RectangleDuring a drag with dragAppearance of either "target" or "outline", returns the page-relative coordinates of whatever element is being dragged.static CanvasReturns the current dragTarget.static CanvasMethod to return thecanvasFocus:truecanvas with current keyboard focus.static StringgetKey()Return the name of the key for the event passed in.static StringReturns the character for a keypress event, derived from theevent.characterValue.static intReturns the numeric characterValue reported by the browser.static StringReturn the natively reported event.code value for the current event (keyboard) event.static StringReturn the natively reported event.key value for the current event.static IntegerReturn the page-relative X (horizontal) coordinate of an event.static IntegerReturn the page-relative Y (vertical) coordinate of an event.static Objectstatic ElementReturns the natively reported target (or source) DOM element for the current mouse event.static StringThis method is a synonym forgetKeyEventKey()static CanvasReturn the canvas that is the target of the mouse event.static floatDeprecated.static doubleDeprecated.in favor ofgetWheelDeltaY()static doubleHorizontal scroll delta reported by amouseWheelevent (such as a horizontal swipe on a track-pad).static doubleApplies tomouseWheelevents only.static intgetX()Return the page-relative X (horizontal) coordinate of an event.static intgetY()Return the page-relative Y (vertical) coordinate of an event.static BooleanReturns true if the left mouse button is being pressed.static booleanReturns true if the middle mouse button is being pressed.static BooleanReturns true if the right mouse button is being pressed.static voidsetDragOffset(int offsetX, int offsetY) Sets the initial coordinate offset of the last event, typically a mouseDown or touchStart, from the drag target.static voidsetDragTracker(String html) Set the HTML for the drag tracker that follows the mouse during a drag and drop interaction.static voidsetDragTracker(String html, int newWidth, int newHeight, int offsetX, int offsetY) Set the HTML for the drag tracker that follows the mouse during a drag and drop interaction.static voidThis API may be called to set the native HTML5 drag tracker image.static voidsetDragTrackerImage(String src, int x) static voidsetDragTrackerImage(String src, int x, int y) This API may be called to set the native HTML5 drag tracker image.static voidsetNativeDragData(Object data) static voidsetNativeDragData(Object data, String strData) static BooleanReturn true if the shift key is being held down.static BooleantargetIsMasked(Canvas target) Return whether this Canvas is masked by a clickMask (seeCanvas.showClickMask()).
- 
Constructor Details- 
EventHandlerpublic EventHandler()
 
- 
- 
Method Details- 
altKeyDownReturn true if the alt (option) key is being held down. Note that this is only set reliably for keyboard events.- Returns:
- true == alt key is down
 
- 
ctrlKeyDownReturn true if the control key is being held down. Note that this is only set reliably for keyboard events.- Returns:
- true == control key is down
 
- 
getDragTargetReturns the current dragTarget. This is the component on which the drag and drop interaction was initiated. This only returns something meaningful during a drag and drop interaction.- Returns:
- The dragTarget.
- See Also:
 
- 
getFocusCanvasMethod to return thecanvasFocus:truecanvas with current keyboard focus.- Returns:
- Current focus canvas
 
- 
getKeyEventCharacterReturns the character for a keypress event, derived from theevent.characterValue.Only available on keyPress events, and only for character (or ascii control) keys. See the Keyboard Events Overviewfor related APIs and more information on keyboard event handling in Smart GWT.- Returns:
- Character the user entered. May be null for non-character keys.
 
- 
getKeyEventCharacterValuepublic static int getKeyEventCharacterValue()Returns the numeric characterValue reported by the browser.Only available on keyPress events, and only for character (or ascii control) keys. See the Keyboard Events Overviewfor related APIs and more information on keyboard event handling in Smart GWT.- Returns:
- Numeric character value reported by the browser (ASCII value of the key pressed)
 
- 
getKeyEventCodeReturn the natively reported event.code value for the current event (keyboard) event.Note that EventHandler.getReportedKey()simply provides access to theevent.codevalue reported by the browser. Smart GWT has no control over whether these values are accurate or vary by browser.See the Keyboard Events Overviewfor related APIs and more information on keyboard event handling in Smart GWT.- Returns:
- Native event.code for the current keyboard event.
 
- 
getKeyEventKeyReturn the natively reported event.key value for the current event.Note that this differs from getKey()in a couple of important ways:- The actual key values
 returned for specific keys     differ in a number of ways. For example alpha characters keys are natively reported as
 either     upper or lower case depending on what would actually by typed,      (whereas getKey()is always uppercase for alpha keys) and the reported name for various 'named' keys (such as the arrow keys differ).
 The full set of native key names is available here, and the Smart GWT key names is available String.
- EventHandler.getKeyEventKey()simply provides access to the- event.keyvalue. As such the reported values are generated by the browser itself and Smart GWT has no control over whether they may vary by browser, etc.
 See the Keyboard Events Overviewfor related APIs and more information on keyboard event handling in Smart GWT.- Returns:
- Native event.key for the current keyboard event.
 
- The actual key values
 returned for specific keys     differ in a number of ways. For example alpha characters keys are natively reported as
 either     upper or lower case depending on what would actually by typed,      (whereas 
- 
getNativeMouseTargetReturns the natively reported target (or source) DOM element for the current mouse event. NOTE: Smart GWT cannot guarantee that the same element will be reported in all browser/platform configurations for all event types. If you wish to make use of this value, we recommend testing your use case in all target browser configurations.- Returns:
- native DOM element over which the mouse event occurred
 
- 
getReportedKeyThis method is a synonym forgetKeyEventKey()- Returns:
- Native event.key for the current keyboard event.
 
- 
getTargetReturn the canvas that is the target of the mouse event. Returns null if no canvas found.- Returns:
- event target canvas
 
- 
getWheelDeltapublic static float getWheelDelta()Deprecated.in favor ofgetWheelDeltaY()Applies tomouseWheelevents only. Returns a numeric value indicating how far the mouse wheel was rotated. This value will be positive if the user scrolled the mousewheel forward or up, or negative if scrolled in the other direction. For a standard wheel-mouse, an increment of 1 relates to the smallest possible rotation of the mouse wheel. For other scrolling devices, such as scroll gestures on a track pad, wheel delta may be reported in finer grained increments (causing this method to return a fractional value).Note that behavior for trackpad scroll-gestures may differ by browser, but where separate vertical and horizontal scroll information is available, this method refers to a vertical scroll gesture. Developers should also be aware that some browsers and operating systems allow the user to configure the sensitivity of the mouse wheel or trackpad, which may change this value. - Returns:
- numeric value indicating how far the mouse wheel was rotated.
 
- 
getWheelDeltaAsDoublepublic static double getWheelDeltaAsDouble()Deprecated.in favor ofgetWheelDeltaY()Applies tomouseWheelevents only. Returns a numeric value indicating how far the mouse wheel was rotated. This value will be positive if the user scrolled the mousewheel forward or up, or negative if scrolled in the other direction. For a standard wheel-mouse, an increment of 1 relates to the smallest possible rotation of the mouse wheel. For other scrolling devices, such as scroll gestures on a track pad, wheel delta may be reported in finer grained increments (causing this method to return a fractional value).Note that behavior for trackpad scroll-gestures may differ by browser, but where separate vertical and horizontal scroll information is available, this method refers to a vertical scroll gesture. Developers should also be aware that some browsers and operating systems allow the user to configure the sensitivity of the mouse wheel or trackpad, which may change this value. - Returns:
- numeric value indicating how far the mouse wheel was rotated.
 
- 
getWheelDeltaXpublic static double getWheelDeltaX()Horizontal scroll delta reported by amouseWheelevent (such as a horizontal swipe on a track-pad).Returns a numeric value indicating how far the mouse wheel was rotated / the magnitude of the scroll gesture. This value will be positive if the user scrolled the mousewheel to the right, negative if scrolled in the other direction. - Returns:
- numeric value indicating how far the mouse wheel was rotated.
- See Also:
 
- 
getWheelDeltaYpublic static double getWheelDeltaY()Applies tomouseWheelevents only. Returns a numeric value indicating how far the mouse wheel was rotated. This value will be positive if the user scrolled the mousewheel forward or up, or negative if scrolled in the other direction. For a standard wheel-mouse, an increment of 1 relates to the smallest possible rotation of the mouse wheel. For other scrolling devices, such as scroll gestures on a track pad, wheel delta may be reported in finer grained increments (causing this method to return a fractional value).Note that behavior for trackpad scroll-gestures may differ by browser, but where separate vertical and horizontal scroll information is available, this method refers to a vertical scroll gesture. Developers should also be aware that some browsers and operating systems allow the user to configure the sensitivity of the mouse wheel or trackpad, which may change this value. - Returns:
- numeric value indicating how far the mouse wheel was rotated.
- See Also:
 
- 
getXpublic static int getX()Return the page-relative X (horizontal) coordinate of an event.- Returns:
- x-coordinate in page coordinate space
 
- 
getYpublic static int getY()Return the page-relative Y (vertical) coordinate of an event.- Returns:
- y-coordinate in page coordinate space
 
- 
leftButtonDownReturns true if the left mouse button is being pressed.- Returns:
- true == left button is down, false == up
- See Also:
 
- 
middleButtonDownpublic static boolean middleButtonDown()Returns true if the middle mouse button is being pressed.Checking whether the middle mouse button is pressed can be used to implement power user shortcuts; however, note that many pointing devices do not have a middle button. Thus, the application should not require the user to press a middle button in order to perform some action. - Returns:
- true if the middle mouse button is pressed; false otherwise.
- See Also:
 
- 
rightButtonDownReturns true if the right mouse button is being pressed.- Returns:
- true == right button is down, false == up
- See Also:
 
- 
setDragOffsetpublic static void setDragOffset(int offsetX, int offsetY) Sets the initial coordinate offset of the last event, typically a mouseDown or touchStart, from the drag target. For example, when grabbing and dragging aScrollbarthumb with the mouse, you'd expect positive coordinates that reflect your position relative to the top, left corner of the thumb. If a drag tracker will be used, callsetDragTracker()instead, which takes optional argumentsoffsetXandoffsetYthat act similarly to those passed to this method.Your canvas can call this method to set the initial drag offset to whatever you want like so: dragStart : function () { isc.EventHandler.setDragOffset(5, 20); }- Parameters:
- offsetX- initial x-offset for the drag
- offsetY- initial y-offset for the drag
- See Also:
 
- 
setDragTrackerImageThis API may be called to set the native HTML5 drag tracker image. Thexandyparameters may be specified to affect the placement of the drag tracker image relative to the mouse cursor. The size of the drag tracker image is the intrinsic size of the image. Browsers may apply certain visual effects (such as a slight transparency) to this image.Can only be called during the Canvas.dragStart()event (or methods called during the handling of that event).NOTES: - Not supported in Opera 12.x or Safari.
- For best results, this image should be preloaded. Otherwise, the image might not appear for the first drag using this image.
- This API does not work in Chrome or Firefox on Windows 7 if the "Use visual styles on windows and buttons" setting is turned off.
 
- 
setDragTrackerImage- See Also:
 
- 
setDragTrackerImageThis API may be called to set the native HTML5 drag tracker image. Thexandyparameters may be specified to affect the placement of the drag tracker image relative to the mouse cursor. The size of the drag tracker image is the intrinsic size of the image. Browsers may apply certain visual effects (such as a slight transparency) to this image.Can only be called during the Canvas.dragStart()event (or methods called during the handling of that event).NOTES: - Not supported in Opera 12.x or Safari.
- For best results, this image should be preloaded. Otherwise, the image might not appear for the first drag using this image.
- This API does not work in Chrome or Firefox on Windows 7 if the "Use visual styles on windows and buttons" setting is turned off.
 - Parameters:
- src- image source. See- SCImgURL
- x- offset-x from the mouse cursor
- y- offset-y from the mouse cursor
 
- 
shiftKeyDownReturn true if the shift key is being held down. Note that this is only set reliably for keyboard events.- Returns:
- true == shift key is down
 
- 
targetIsMaskedReturn whether this Canvas is masked by a clickMask (seeCanvas.showClickMask()).- Parameters:
- target- widget to check.
- Returns:
- true if masked, false if not masked.
 
- 
setDragTrackerSet the HTML for the drag tracker that follows the mouse during a drag and drop interaction.Your canvas can use this routine to set the drag tracker to whatever HTML you want like so: dragStart : function () { isc.EventHandler.setDragTracker('Your contents here'); }- Parameters:
- html- HTML for the tracker
 
- 
setDragTrackerpublic static void setDragTracker(String html, int newWidth, int newHeight, int offsetX, int offsetY) Set the HTML for the drag tracker that follows the mouse during a drag and drop interaction.Your canvas can use this routine to set the drag tracker to whatever HTML you want like so: dragStart : function () { isc.EventHandler.setDragTracker('Your contents here'); }- Parameters:
- html- HTML for the tracker
- newWidth- new width for the tracker
- newHeight- new height for the tracker
- offsetX- x-offset for the tracker
- offsetY- y-offset for the tracker
 
- 
getDragRectDuring a drag with dragAppearance of either "target" or "outline", returns the page-relative coordinates of whatever element is being dragged. Calling this method allows you to write drag and drop logic that works identically even if dragAppearance is subsequently changed.- Returns:
- lobal (page-relative) coordinates and size of the dragged element, as a 4-element array [left,top,width,height], or null if not dragging
 
- 
getMouseDownXReturn the page-relative X (horizontal) coordinate of an event.- Returns:
- x-coordinate in page coordinate space
 
- 
getMouseDownYReturn the page-relative Y (vertical) coordinate of an event.- Returns:
- y-coordinate in page coordinate space
 
- 
getNativeDragData
- 
setNativeDragData
- 
setNativeDragData
- 
getKeyReturn the name of the key for the event passed in. Note that this is only set reliably for keyboard events.Strings to identify the various keys on the keyboard. For alpha keys, the single (uppercase) character value is used, such as "Q" For Numeric keys, the number is used as in a single character string, like "1" Function keys are identified as "f1" - "f12" Non alpha-numeric character keys (such as the key for "[" / "{") are identified by their unmodified character value (the value obtained by hitting the key without holding shift down), by default - exceptions are listed below. Additional key names: - Space - Tab - Enter - Escape - Backspace - Insert - Delete - Arrow_Up - Arrow_Down - Arrow_Left - Arrow_Right - Home - End - Page_Up - Page_Down - Shift - Ctrl - Alt [Note: Some keys may not be available for capture on every platform]- Returns:
- the key name
- See Also:
 
 
- 
getWheelDeltaY()