homesciterEvent

Event object

Represents user interface event. Events and correspndent event handlers are defined in Events.

Constants

Event Group codes (used with Element.subscribe() method)

MOUSE mouse events group
KEY key events group
FOCUS focus events group
BEHAVIOR_EVENT group of events generated (synthesized) by particular behaviors (like BUTTON_CLICK, EDIT_VALUE_CHANGING, etc.)
SCROLL scroll events group
SIZE size events group (that is just single event, onSize)

Mouse event codes

MOUSE_ENTER type of event, mouse enters the element.
MOUSE_LEAVE type of event, mouse leaves the element.
MOUSE_MOVE type of event, mouse moves over the element.
MOUSE_DOWN type of event, mouse button pressed in the element.
MOUSE_UP type of event, mouse button released in the element.
MOUSE_DCLICK type of event, mouse clicked twice in the element.
MOUSE_WHEEL type of event, mouse wheel rotated.
MOUSE_TICK type of event, mouse timer event. Runtime sends this event regularly when mouse button is pressed on the element.
MOUSE_IDLE type of event, mouse timer event. Runtime sends this event when mouse is over the element, not pressed and not moving for some time. By default this event triggers popup of tooltip.

Keyboard event codes

KEY_DOWN type of event, key pressed when element or one of its children is in focus.
KEY_UP type of event, key released when element or one of its children is in focus.
KEY_CHAR type of event, character key pressed when element or one of its children is in focus.

Scroll event codes

SCROLL_HOME
SCROLL_END
SCROLL_STEP_PLUS
SCROLL_STEP_MINUS
SCROLL_PAGE_PLUS
SCROLL_PAGE_MINUS
SCROLL_POS

Gesture (touch screen) event codes

GESTURE_REQUEST The engine sends this event to request list of gestures that the element supports. Set "ORed" flags in Event.flags field. List of supported flags/gesture types:
  • Event.GESTURE_FLAG_ZOOM  - two fingers zoom;
  • Event.GESTURE_FLAG_ROTATE  - two fingers rotate;
  • Event.GESTURE_FLAG_PAN_VERTICAL - vertical swipe or panning;
  • Event.GESTURE_FLAG_PAN_HORIZONTAL- horizontal swipe or panning;
  • Event.GESTURE_FLAG_TAP1 - press-and-tap gesture;
  • Event.GESTURE_FLAG_TAP2 - tap by two fingers;
  • Event.GESTURE_FLAG_PAN_WITH_GUTTER  -  PAN_VERTICAL and PAN_HORIZONTAL modifier - gutter.
  • Event.GESTURE_FLAG_PAN_WITH_INERTIA  -  PAN_VERTICAL and PAN_HORIZONTAL modifier - generate inertia events.
  • Event.GESTURE_FLAGS_ALL  - all flags/events
GESTURE_ZOOM The zoom gesture. Event.deltaV  field contains float > 1.0 in case of zoom-out and float < 1.0 for zoom-in.
GESTURE_PAN The pan/swipe gesture. Event.deltaX and Event.deltaY fields contain integers - number of pixels in X and Y directions.
GESTURE_ROTATE The rotation gesture. Event.deltaV  field contains delta angle (in radians).
GESTURE_TAP1 The press and tap gesture.
GESTURE_TAP2 Tap by two fingers gesture.
Event.flags in all events (but not in GESTURE_REQUEST) is ORed combination of the following states:
  • Event.GESTURE_STATE_BEGIN - is "on" for first event in the gesture sequence.
  • Event.GESTURE_STATE_INERTIA - is "on" for events synthesized by the inertia processor.
  • Event.GESTURE_STATE_END - is "on" for last event in the gesture sequence.

Focus event codes

LOST_FOCUS
GOT_FOCUS

Logical event codes from builtin behaviors

BUTTON_CLICK
BUTTON_PRESS
BUTTON_STATE_CHANGED Checkbox/radio state was changed. ( Not all BUTTON_CLICKs are changing state of those. )
EDIT_VALUE_CHANGING
EDIT_VALUE_CHANGED
SELECT_SELECTION_CHANGED
SELECT_STATE_CHANGED
HYPERLINK_CLICK
ACTIVATE_CHILD
POPUP_REQUEST
POPUP_READY
POPUP_DISMISSED
POPUP_DISMISSING
MENU_ITEM_ACTIVE Mouse over the menu item, Event.target is a menu item, Event.owner - initiator of the menu  
MENU_ITEM_CLICK Click on the menu item, Event.target is a menu item, Event.owner - initiator of the menu
CONTEXT_MENU_REQUEST Is sent by the engine when context menu needs to be shown. evt.target is a top element that have got e.g. right mous click. evt.source [read/write] is a menu element that is about to popup. You can set your own menu element to the evt.source field while handling this event.
CONTEXT_MENU_SETUP Is sent by the engine when context menu is found. evt.source is the menu element that you can modify at this point.
VISUAL_STATUS_CHANGED Notification that the element changed its visibility either by changing display or visibility CSS attributes. The event is sent only to the element itself (so not a bubbling event).
DISABLED_STATUS_CHANGED Notification that the element or one of its containers have changed its disabled status.
DRAGGING_MOVE
DRAGGING_COPY
Values of the draggingMode attribute below.
REQUEST_TOOLTIP
Request for tooltip, the event is sent in respnse of MOUSE_IDLE. Element on evt.source is a proposed tooltip element. You can assign your own DOM element to the evt.source field. To cancel tooltip generation set evt.source to null and return true (event handled) from the event handler.
DOCUMENT_COMPLETE
Notification that document finishes its loading - all requests for external resources are finished. evt.target is the root node ( <html> ) of the document that is complete. Note that the event is being generated even some of resources were not available. DOM elements that contain non-available resources will get :incomplete state flag.
FORM_SUBMIT
behavior:form detected submission event from button type=reset. evt.data field contains data to be sent to the server as a map (object). You can modify the data or discard submission by returning true ("event consumed") from the event handler.
FORM_RESET
behavior:form detected reset event (from button type=reset). evt.data field contains data to be set to input fields.

Event flags

SINKING
Event dispatching direction. If this flag set then event is being dispatched in the direction from parent to child. Example:
switch(evt.type)
{
   case Event.MOUSE_DOWN | Event.SINKING:
        // handle thr event before any child
   case Event.MOUSE_DOWN:
        // it is here as no one child processed it.
}
HANDLED
Event was handled (event handler function returned true) by some child of the element or behavior. Example:
switch(evt.type)
{
   case Event.MOUSE_DOWN:
       // after all children and no one has handled it.
   case Event.MOUSE_DOWN | Event.HANDLED:
       // after all children, and some child has handled it.
}

Virtual key codes - values of keyCode filed in KEY_DOWN and KEY_UP events

VK_CANCEL   VK_BACK     VK_TAB      VK_CLEAR    VK_RETURN   VK_SHIFT    VK_CONTROL
VK_MENU     VK_PAUSE    VK_CAPITAL  VK_KANA     VK_HANGUL   VK_JUNJA    VK_FINAL
VK_HANJA    VK_KANJI    VK_ESCAPE   VK_CONVERT  VK_SPACE    VK_PRIOR    VK_NEXT
VK_END      VK_HOME     VK_LEFT     VK_UP       VK_RIGHT    VK_DOWN     VK_SELECT
VK_PRINT    VK_EXECUTE  VK_SNAPSHOT VK_INSERT   VK_DELETE   VK_HELP     VK_SLEEP
VK_NUMPAD0  VK_NUMPAD1  VK_NUMPAD2  VK_NUMPAD3  VK_NUMPAD4  VK_NUMPAD5  VK_NUMPAD6
VK_NUMPAD7  VK_NUMPAD8  VK_NUMPAD9  VK_MULTIPLY VK_ADD      VK_SEPARATOR VK_SUBTRACT
VK_DECIMAL  VK_DIVIDE   VK_F1       VK_F2       VK_F3       VK_F4       VK_F5
VK_F6       VK_F7       VK_F8       VK_F9       VK_F10      VK_F11      VK_F12
VK_F13      VK_F14      VK_F15      VK_F16      VK_F17      VK_F18      VK_F19
VK_F20      VK_F21      VK_F22      VK_F23      VK_F24

Example:

switch(event.keyCode)
{
  case Event.VK_HOME: index = 0; break;
  case Event.VK_END: index = this.length - 1; break;
}

Properties

type r - Integer, type of the event, value equal to one of the constant above.
altKey r - true/false, true if ALT key pressed. Valid for Mouse, Key events.
ctrlKey r - true/false, true if CTRL key pressed. Valid for Mouse, Key events.
shiftKey r - true/false, true if SHIFT key pressed. Valid for Mouse, Key events.
mainButton r - true/false, true if main mouse button pressed (usually left mouse button). Valid for Mouse events.
propButton r - true/false, true if property mouse button pressed (usually right mouse button). Valid for Mouse events.
target r - Element,  element this event tageted to.
reason r/w - integer, reason field of control event code.
keyCode r - integer, key scan code for KEY_DOWN/KEY_UP events and unicode codepoint of the character pressed for the KEY_CHAR event.
group r - symbol, event group symbol, here it is a symbol of event handler function: #onMouse, #onKey, #onFocus, etc.
wheelDelta r - mouse wheel "tick" - valid in onMouse/MOUSE_WHEEL event.
scrollPos r - scroll position in SCROLL_POS event.
x r - integer, x coordinate of the mouse event relative to the element itself (origin of its content box)
y r - integer, y coordinate of the mouse event relative to the element itself (origin of its content box)
xRoot r - integer, x coordinate of the mouse event relative to the element's root element (<html>). As root element spans the whole view area then it is also view relative coordinate.
yRoot r -integer, y coordinate of the mouse event relative to the element's root element (<html>).
xScreen r - integer, x coordinate of the mouse event relative to the screen.
yScreen r -integer, y coordinate of the mouse event relative to the screen.
owner rw - Element, owner (initiator) of the menu in MENU_ITEM_CLICK, also this is value of last parameter in Element.sendEvent method.
isOnIcon r - true | false, onMouse(evt) only. true if mouse is on icon area. Element icon is foreground, no-repeat image.
dragging r/w - Element, onMouse(evt) and onExchange(evt) only. Reference of element being dragged when onMouse and data being dragged when onExchange().
draggingMode r/w - integer, onMouse(evt) only. Dragging mode - either Event.DRAGGING_MOVE or Event.DRAGGING_COPY - current dragging mode.
draggingDataType r - symbol,  onExchange(evt) only. One of the following values:
  • #text -
  • #html
  • #url
  • #file
  • #json
deltaV, deltaX, deltaY, flags - onGesture() event specific fields. See prose above about GESTURE_**** values.

Sciter

License and source code access

Documentation

Classes and objects
Download