events

There’s an Event Dispatcher i.e

from domonic.events import *

class SomeEventHandler(EventDispatcher):

    def __init__(self):
        super().__init__(self)
        self.addEventListener('some_event', self.on_custom_event)

    def on_custom_event(evt):
        print('that just happened')

my_handler = SomeEventHandler()
my_handler.dispatchEvent('some_event')

If you create a python virtual DOM with domonic you can listen for events like so…

def on_page_clicked(evt):
        print('the page was just clicked', evt)
        print('mouseX', evt.x)
        print('mouseY', evt.y)

page.addEventListener( MouseEvent.CLICK, on_page_clicked )
  • above example needs a MouseEvent relaying or dispatching from somewhere. i.e. examples/events

domonic.events

https://developer.mozilla.org/en-US/docs/Web/Events

class domonic.events.AnimationEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
ANIMATIONEND: str = 'animationend'
ANIMATIONITERATION: str = 'animationiteration'
ANIMATIONSTART: str = 'animationstart'
animationName

Returns the name of the animation

elapsedTime

Returns the number of seconds an animation has been running

pseudoElement

Returns the name of the pseudo-element of the animation

class domonic.events.BeforeUnloadEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
BEFOREUNLOAD: str = 'beforeunload'

BeforeUnloadEvent

class domonic.events.ClipboardEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
COPY: str = 'copy'
CUT: str = 'cut'
PASTE: str = 'paste'
clipboardData

Returns an object containing the data affected by the clipboard operation

class domonic.events.CompositionEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
class domonic.events.CustomEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
class domonic.events.DOMContentLoadedEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
DOMCONTENTLOADED: str = 'DOMContentLoaded'
document

Returns the document that was loaded

class domonic.events.DragEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
DRAG: str = 'drag'
DROP: str = 'drop'
END: str = 'dragend'
ENTER: str = 'dragenter'
EXIT: str = 'dragexit'
LEAVE: str = 'dragleave'
OVER: str = 'dragover'
START: str = 'dragstart'
dataTransfer

Returns the data that is dragged/dropped

class domonic.events.ErrorEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
ERROR: str = 'error'
class domonic.events.Event(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]

event

ABORT: str = 'abort'
AFTERPRINT: str = 'afterprint'
BEFOREPRINT: str = 'beforeprint'
BEFOREUNLOAD: str = 'beforeunload'
CANPLAY: str = 'canplay'
CANPLAYTHROUGH: str = 'canplaythrough'
CHANGE: str = 'change'
DURATIONCHANGE: str = 'durationchange'
EMPTIED: str = 'emptied'
ENDED: str = 'ended'
ERROR: str = 'error'
FULLSCREENCHANGE: str = 'fullscreenchange'
FULLSCREENERROR: str = 'fullscreenerror'
INPUT: str = 'input'
INVALID: str = 'invalid'
LOAD: str = 'load'
LOADEDDATA: str = 'loadeddata'
LOADEDMETADATA: str = 'loadedmetadata'
MESSAGE: str = 'message'
OFFLINE: str = 'offline'
ONLINE: str = 'online'
OPEN: str = 'open'
PAUSE: str = 'pause'
PLAY: str = 'play'
PLAYING: str = 'playing'
PROGRESS: str = 'progress'
RATECHANGE: str = 'ratechange'
READYSTATECHANGE: str = 'readystatechange'
RESET: str = 'reset'
RESIZE: str = 'resize'
SCROLL: str = 'scroll'
SEARCH: str = 'search'
SEEKED: str = 'seeked'
SEEKING: str = 'seeking'
SELECT: str = 'select'
SHOW: str = 'show'
STALLED: str = 'stalled'
SUBMIT: str = 'submit'
SUSPEND: str = 'suspend'
TOGGLE: str = 'toggle'
UNLOAD: str = 'unload'
VOLUMECHANGE: str = 'volumechange'
WAITING: str = 'waiting'
stopPropagation()[source]

[prevents further propagation of the current event in the capturing and bubbling phases]

domonic.events.EventDispatcher

legacy alias

class domonic.events.EventTarget(*args, **kwargs)[source]

EventTarget is a class you can extend to give your obj event dispatching abilities

class domonic.events.ExtendableEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
extendable

Returns whether the event is extendable or not

timeStamp: float

Returns the time stamp of the event

class domonic.events.FetchEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
FETCH: str = 'fetch'
clientId

Returns the client ID of the fetch request

property isReload

Returns whether the request is a reload or not

request

Returns the request object

respondWith(response)[source]

Returns a promise that resolves to the response object

waitUntil(promise)[source]

Returns a promise that resolves when the response is available

class domonic.events.FocusEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
BLUR: str = 'blur'
FOCUS: str = 'focus'
FOCUSIN: str = 'focusin'
FOCUSOUT: str = 'focusout'
class domonic.events.GamePadEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
START: str = 'gamepadconnected'
STOP: str = 'gamepaddisconnected'
class domonic.events.HashChangeEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
CHANGE: str = 'hashchange'
class domonic.events.InputEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
CHANGE: str = 'change'
INPUT: str = 'input'
SELECT: str = 'select'
data

Returns the inserted characters

dataTransfer

Returns an object containing information about the inserted/deleted data

getTargetRanges()[source]

Returns an array containing target ranges that will be affected by the insertion/deletion

inputType

Returns the type of the change (i.e “inserting” or “deleting”)

isComposing

Returns whether the state of the event is composing or not

class domonic.events.KeyboardEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]

keyboard events

DOM_KEY_LOCATION_JOYSTICK: int = 5
DOM_KEY_LOCATION_LEFT: int = 0
DOM_KEY_LOCATION_MOBILE: int = 4
DOM_KEY_LOCATION_NUMPAD: int = 3
DOM_KEY_LOCATION_RIGHT: int = 2
DOM_KEY_LOCATION_STANDARD: int = 1
KEYDOWN: str = 'keydown'
KEYPRESS: str = 'keypress'
KEYUP: str = 'keyup'
class domonic.events.MessageEvent(_type, options: Optional[dict] = None, *args, **kwargs)[source]
CONNECT: str = 'connect'
DISCONNECT: str = 'disconnect'
MESSAGE: str = 'message'
data

Returns the data of the message

lastEventId

Returns the last event id of the message

origin

Returns the origin of the message

ports

Returns the ports of the message

source

Returns the source of the message

class domonic.events.MouseEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]

mouse events

CLICK: str = 'click'
CONTEXTMENU: str = 'contextmenu'
DBLCLICK: str = 'dblclick'
MOUSEDOWN: str = 'mousedown'
MOUSEENTER: str = 'mouseenter'
MOUSELEAVE: str = 'mouseleave'
MOUSEMOVE: str = 'mousemove'
MOUSEOUT: str = 'mouseout'
MOUSEOVER: str = 'mouseover'
MOUSEUP: str = 'mouseup'
getModifierState()[source]

Returns an array containing target ranges that will be affected by the insertion/deletion

class domonic.events.PageTransitionEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
PAGEHIDE: str = 'pagehide'
PAGESHOW: str = 'pageshow'
persisted

Returns whether the webpage was cached by the browser

class domonic.events.PointerEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
POINTER: str = 'pointer'
POINTERCANCEL: str = 'pointercancel'
POINTERDOWN: str = 'pointerdown'
POINTERENTER: str = 'pointerenter'
POINTERLEAVE: str = 'pointerleave'
POINTERMOVE: str = 'pointermove'
POINTEROUT: str = 'pointerout'
POINTEROVER: str = 'pointerover'
POINTERUP: str = 'pointerup'
class domonic.events.PopStateEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
POPSTATE: str = 'popstate'
state

Returns an object containing a copy of the history entries

class domonic.events.ProgressEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
ABORT: str = 'abort'
ERROR: str = 'error'
LOAD: str = 'load'
LOADED: str = 'loaded'
LOADEND: str = 'loadend'
LOADSTART: str = 'loadstart'
PROGRESS: str = 'progress'
TIMEOUT: str = 'timeout'
class domonic.events.PromiseRejectionEvent(_type, options=None, *args, **kwargs)[source]
HANDLED: str = 'rejectionhandled'
UNHANDLED: str = 'unhandledrejection'
isRejected

Returns whether the promise was rejected or not

promise

Returns the promise that was rejected

reason

Returns the reason of the rejection

class domonic.events.SVGEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
ABORT: str = 'abort'
ERROR: str = 'error'
LOAD: str = 'load'
LOADEDDATA: str = 'loadeddata'
LOADEDMETADATA: str = 'loadedmetadata'
LOADSTART: str = 'loadstart'
PROGRESS: str = 'progress'
SCROLL: str = 'scroll'
UNLOAD: str = 'unload'
class domonic.events.SecurityPolicyViolationEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
SECURITY_POLICY_VIOLATION: str = 'securitypolicyviolation'
blockedURI

Returns the blocked URI

frame

Returns the frame that violated the policy

isFrameAncestor

Returns whether the frame is an ancestor of the frame that violated the policy

isMainFrame

Returns whether the frame is the main frame

originalPolicy

Returns the original policy

timeStamp: float

Returns the time stamp of the event

violatedDirective

Returns the violated directive

class domonic.events.StorageEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
STORAGE: str = 'storage'
key

Returns the key of the changed storage item

newValue

Returns the new value of the changed storage item

oldValue

Returns the old value of the changed storage item

storageArea

Returns an object representing the affected storage object

url

Returns the URL of the changed item’s document

class domonic.events.SubmitEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
SUBMIT: str = 'submit'
class domonic.events.SyncEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
SYNC: str = 'sync'
lastChance

Returns whether the sync event is the last chance or not

tag

Returns the tag of the sync event

timeStamp: float

Returns the time stamp of the event

class domonic.events.TimerEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
TIMER: str = 'timer'
TIMER_COMPLETE: str = 'timercomplete'

TimerEvent

class domonic.events.TouchEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
TOUCHCANCEL: str = 'touchcancel'
TOUCHEND: str = 'touchend'
TOUCHMOVE: str = 'touchmove'
TOUCHSTART: str = 'touchstart'
class domonic.events.TransitionEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
TRANSITIONEND: str = 'transitionend'
elapsedTime

Returns the number of seconds a transition has been running

propertyName

Returns the name of the transition

pseudoElement

Returns the name of the pseudo-element of the transition

class domonic.events.TweenEvent(_type, source=None, bubbles=False, cancelable=False)[source]
COMPLETE: str = 'onComplete'
PAUSE: str = 'onPause'
RESET: str = 'onReset'
START: str = 'onStart'
STOP: str = 'onStop'
TIMER: str = 'onTimer'
UNPAUSE: str = 'onUnPause'
UPDATE_END: str = 'onUpdateEnd'
UPDATE_START: str = 'onUpdateStart'
class domonic.events.UIEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
class domonic.events.WheelEvent(_type: str, options: Optional[dict] = None, *args, **kwargs)[source]
WHEEL: str = 'wheel'