Skip to main content

class Event

properties:

  • event.bubbles

  • event.cancelable

  • event.currentTarget

  • event.defaultPrevented

  • event.eventPhase

  • event.target

  • event.type - "click", "mousedown", etc.

  • event.namespace - namespace portion (after the dot) of event name. Like "comp" in "click.comp" event.

  • event.data:any

  • event.details:any - alias of event.data

  • event.keyCode:integer - key code, see include/sciter-x-key-codes.h

  • event.platformKeyCode - platform's native key code, e.g, wParam in WM_KEYDOWN on Windows.

  • event.code - string representation of keyCode KeyA, F1, Enter...

  • event.altKey - ALT true/false

  • event.ctrlKey

  • event.metaKey - command key on OSX, win on Windows

  • event.shiftKey

  • event.isOnIcon - mouse events, Sciter specific, true if mouse is on element icon - foreground-image area, if it is defined by CSS.

  • event.button

  • event.buttons

  • currentTarget relative coordinates:

    • event.x:number, CSS pixels
    • event.y:number, CSS pixels
    • event.position:Point, CSS pixels
    • event.contentPosition:Point, CSS pixels : event.position + event.currentTarget.scrollPosition
  • Client relative coordinates, relative to document container (window|frame):

    • event.clientX:number, CSS pixels
    • event.clientY:number, CSS pixels
    • event.clientPoisition:Point, CSS pixels
  • Window relative coordinates:

    • event.windowX:number, CSS pixels
    • event.windowY:number, CSS pixels
    • event.windowPoisition:Point, CSS pixels
  • Screen relative coordinates, relative to whole desktop:

    • event.screenX:number, screen pixels
    • event.screenY:number, screen pixels
    • event.screenPosition:Point, screen pixels
  • Scroll (e.g. mouse wheel) deltas:

    • event.deltaX :number
    • event.deltaY :number
    • event.delta:Size
  • event.deltaMode|int - 0 - deltaX/Y are pixels coming from touch devices, 1 - deltaX/Y are in lines (a.k.a. mouse wheel ticks).

  • event.relatedTarget - only for blur|focus|focusin|focusout events, see: relatedTarget.

properties (Sciter specific):

  • event.x - sciter specific, coordinates are relative
  • event.y - to event.currentTarget - the element this event handler is attached to.
  • event.source - used in some events to indicate auxiliary source element.
  • event.isOnIcon:Element - mouse events, it is set to element when mouse is on icon of that element. Element icon is an element's foreground-image (if any) so event.isOnIcon is on when mouse is over area where the image is rendered.
  • event.reason - integer, event type specific flags.

properties (Sciter specific, gestures):

  • event.delta:Size pan gesture deltas, in logical (CSS) pixels;
  • event.deltaZoom:float zoom gesture delta zoom multiplier: currentScale *= evt.deltaZoom;
  • event.deltaRotation:Angle zoom gesture delta angle: currentRotation += evt.deltaRotation;

methods:

  • event.preventDefault()
  • event.stopImmediatePropagation()
  • event.stopPropagation()

static methods:

  • Event.keyState(key:string): true|false|undefined

    Returns pressed status of the key. Example:

      if(Event.keyState(`CapsLock`))
    ... CAPS LOCK is on ...
  • Event.cursorPos(): [x,y]

    Reports current cursor position relative to desktop, example:

    let [xpos,ypos] = Event.cursorPos();

Known Events

Mouse

namealt namedescription
mousemovemouse-move
mouseentermouse-enter
mouseleavemouse-leave
mouseovermouse-overfor the difference between mosueenter and mouseover see MDN
mouseoutmouse-outfor the difference between mosueleave and mouseout see MDN
mouseidlemouse-idlemouse stays not moving in the element, the event triggers tooltip show.
mousetickmouse-tickmouse is pressed for some time in element, periodic "pulse" event.
mousedownmouse-down
mouseupmouse-up
wheelmouse-wheel
mousedragrequestmouse-drag-requestpressed mouse starts moving after system defined threshold
singleclicksingle-click\
dblclickdouble-click- either one of these events generated.
tripleclicktriple-click/

Behaviors

namealt namedescription
click
pressmouse down on clickable element
inputposted event, arrived after user changes something.
changesynchronous event, arrived on user's change and before screen update.
changingbefore change, in text editors
submitin <form>
resetin <form>
expandnotification that some element was expanded (opened), e.g. option in `<select
collapsenotification that some element was collapsed (closed), e.g. option in `<select
statechangestate-changeUI state change, e.g. caret was moved by the user, splitter moved in frameset, etc.
currentstatechangecurrent-state-change:current state change (select,menu).
disabledstatechangedisabled-state-change
readonlystatechangereadonly-state-change
navigationThe event is generated in response of click on a hyperlink. event.data is an object { url:string, target:string }. Consuming this event in sinking phase will prevent default loading of target document into window or frame.
contextmenucontext-menucontext menu request for the element
contextmenusetupcontext-menu-setupnotification to setup context menu, context menu DO< element is event.source
animationendanimation-end
animationstartanimation-start
animationloopanimation-loop
transitionendtransition-end
transitionstarttransition-start
mediachangemedia-changethe event is sent to the window only when media variables have changed
contentchangecontent-changeDOM change notification: elements added or removed, attrributes changed
inputlangchangeinput-lang-changeuser has switched input language
pastehtmlpaste-htmlis sent by behavior:htmlarea on paste of HTML from clipboard
pastetextpaste-textis sent by behavior:htmlarea on paste of plain text from clipboard
pasteimagepaste-imageis sent by behavior:htmlarea on paste of image from clipboard
popuprequestpopup-requestsee popup life-cycle events
popupreadypopupreadysee popup life-cycle events
popupdismissingpopup-dismissingsee popup life-cycle events
popupdismissedpopup-dismissedsee popup life-cycle events
tooltiprequesttooltip-requestsee popup life-cycle events

Focus

namealt namedescription
focusinfocus-insent to a container when focus moves on a child inside it
focusoutfocus-outsent to a container when focus moves outside of it
focus
blur

Keyboard

namealt namedescription
keydownkey-downkeyboard key pressed
keyupkey-upkeyboard key depressed
keypresskey-charkeyboard key pressed and depressed, key code was translated to produce event.char
compositionstartcomposition-startIME composition started
compositionendcomposition-endIME composition ended

Scroll

namealt namedescription
scrollis sent to scrollable element after its scroll position changed
scrollanimationstartscroll-animation-startis sent to scrollable element on scroll animation start
scrollanimationendscroll-animation-endis sent to scrollable element on scroll animation end
scrollstepplusscroll-step-plusclick on the part of a scrollbar
scrollstepminusscroll-step-minusclick on the part of a scrollbar
scrollpageplusscroll-page-plusclick on the part of a scrollbar
scrollpageminusscroll-page-minusclick on the part of a scrollbar
scrollsliderpressscroll-slider-pressscroll slider pressed
scrollsliderreleasescroll-slider-releasescroll slider released

Gestures

Set of events coming from touch devices - touchpad/trackpad or touchscreen.

namealt namedescription
gesturestartgesture-startsee Gesture Handling Initiation
gestureendgesture-endthe event is sent after last touch contact is removed.
gesturepressgesture-pressthe event is sent when the element is touched. For eaxample Android shows expanding circle animation on such event.
gesturepinchgesture-pinchclick
gesturepangesture-panpan (scroll) gesture event.
gestureswipegesture-swipeswipe (fast pan) gesture event.

Gesture Handling

For element to receive gesture events it shall handle the gesture-start event. The event is sent when first touch contact is made.

Element that receives this event may call element.state.wantsGestures(...) method to define gestures it wants to receive.

element.state.wantsGestures(event1,event2,...) accepts list of events of gestures the element wants to receive:

  • "pan-vertical" - vertical scroll
  • "pan-horizontal" - horizontal scroll
  • "zoom"
  • "rotation"
caution

element.state.wantsGestures() method is expected to be called in gesture-start event handler only.

tip

If "rotation" gesture is requested use event.deltaRotation in gesture-pinch handler to get delta angle.

If "zoom" gesture is requested use event.deltaZoom in gesture-pinch handler to get the delta zoom.

Document lifecycle events

Loading:

namealt namedescription
parseddocument-parseddocument just got a DOM structure, scripts are not run yet. This event can be handled by document container only (window or frame).
DOMContentLoadeddocument-readydocument loaded, DOM is parsed, scripts are loaded and run.
completedocument-completedocument loaded in full, scripts were run, all resources defined in HTML are finished loading (with success or failure).

Closing:

namealt namedescription
closerequestdocument-unload-requestfirst phase of document closure, it can be rejected at this point by calling event.preventDefault().
beforeunloaddocument-before-unloaddocument is about to be unloaded, script namespace is still operational.
unloaddocument-unloaddocument is closed and about to be deleted soon.

Element's state change

note

These are not a bubbling events - delivered only to the element itself.

namealt namedescription
sizechangesize-changechange of element dimensions detected
visualstatechangevisibility-state-changeelement become visible or invisible, for example due to visibility value change. event.reason is truthy if it become visible.

Image

namealt namedescription
loadimage-loadimage has been loaded
errorimage-errorimage load error occured

Pager (print preview)

<frame|pager> (print preview) related events

namealt namedescription
paginationstartpagination-startpagination has been started on the frame/pager
paginationpagepagination-pagepagination of one page complete
paginationendpagination-endedpagination has been ended

Drag-n-drop

System drag-n-drop events:

namealt namedescription
dragD&D cursor moves over the element
dragenterdrag-enterD&D cursor enters the element
dragleavedrag-leaveD&D cursor leaves the element
dropUser drops the data by releasing primary mouse button
dragcanceldrag-cancelUser cancels D&D operation by pressing ESC.
willacceptdropwill-accept-dropsee below

Accepting Drag-n-Drop

For an element, in order to accept drop from system's D&D, it should handle will-accept-drop event and if event.detail contains acceptable data and consume the event by calling event.stopPropagation()

In D&D events event.detail is an object with the following fields

  • dataType - string, primary format, one of: "text","html","file" or "json".
  • data - object, may contain one or several fields:
    • text: string - plain text data;
    • html: string - HTML data;
    • file : [path1,path2,...] | path0 - single or multiple file names;
    • json: any - any data that can be JSON.stringify'ed;

Initiating Drag-n-Drop

Call window.performDrag(...) to initiate D&D operation.

event.detail = { dataType: ...; data: {} }

Video

<video> related events

namealt namedescription
videoreadyvideo-ready
videostartvideo-start
videostopvideo-stop
videocoordinatevideo-coordinate
videoframereadyvideo-frame-ready

MISC