Event API¶
-
class
wdom.event.Event(type: str, init: typing.Dict[str, typing.Any] = None) → None[source]¶ Bases:
objectBase class of Event classes.
Create event object.
First argument (type) is a string to represents type of this event. Second optional argument (init) is a dictionally, which has fields for this event’s status.
-
currentTarget¶ Return current event target.
Return type: Optional[WebEventTarget]
-
target¶ Return original event target, which emitted this event first.
Return type: Optional[WebEventTarget]
-
-
class
wdom.event.MouseEvent(type: str, init: typing.Dict[str, typing.Any] = None) → None[source]¶ Bases:
wdom.event.UIEventMouse event class.
Event types generate this event class are
click,dblclick,mouseup, andmousedown.This class has the following attributes:
altKey, button, clientX, clientY, ctrlKey, metaKey, movementX, movementY, offsetX, offsetY, pageX, pageY, region, screenX, screenY, shiftKey, x, y
For details of the attributes, see MouseEvent - Web APIs | MDN
-
class
wdom.event.KeyboardEvent(type: str, init: typing.Dict[str, typing.Any] = None) → None[source]¶ Bases:
wdom.event.UIEventKeyboard event class.
Event types generate this event class are
keydown,keypress, andkeyup.This class has the following attributes:
altKey, code, ctrlKey, key, locale, metaKey, repeat, shiftKey
For details of the attributes, see KeyboardEvent - Web APIs | MDN
-
class
wdom.event.DragEvent(type: str, init: typing.Dict[str, typing.Any] = None) → None[source]¶ Bases:
wdom.event.MouseEventDrag event class.
This class inherits
MouseEventclass and has own attribute dataTransfer, which isDataTransfercontaining data send by this drag event.Event types generate this event class are
drag,dragend,dragenter,dragexit,dragleave,dragover,dragstart, anddrop.
-
class
wdom.event.DataTransfer(id: str = '') → None[source]¶ Bases:
objectDataTransfer object is used to transfer drag/drop data.
TODO: Currently always read/write enabled. https://html.spec.whatwg.org/multipage/dnd.html#drag-data-store-mode
Initialize a new empty DataTransfer object with id.
-
length¶ Return number of items in this DataTransfer object.
Return type: int
-
getData(type)[source]¶ Get data of type format.
If this DataTransfer object does not have type data, return empty string. :arg str type: Data format of the data, like ‘text/plain’.
Return type: str
-
-
wdom.event.create_event(msg)[source]¶ Create Event from JSOM msg and set target nodes.
Parameters: - currentTarget (EventTarget) – Current event target node.
- target (EventTarget) – Node which emitted this event first.
- init (dict) – Event options.
Return type:
-
class
wdom.event.EventListener(listener: typing.Union[typing.Callable[[wdom.event.Event], NoneType], typing.Callable[[wdom.event.Event], typing.Awaitable[NoneType]]]) → None[source]¶ Bases:
objectClass to wrap an event listener function.
Acceptable listeners are function, coroutine, and coroutine-function. If listener is a coroutine or coroutine-function, it will be executed synchronously as if it is normal function.
Wrap an event listener.
Event listener should be function or coroutine-function.
-
class
wdom.event.EventTarget(*args: typing.Any, **kwargs: typing.Any) → None[source]¶ Bases:
objectBase class for EventTargets.
This class and subclasses can add/remove event listeners and emit events.
-
addEventListener(event, listener)[source]¶ Add event listener to this node.
eventis a string which determines the event type when the new listener called. Acceptable events are same as JavaScript, withouton. For example, to add a listener which is called when this node is clicked, event is'click.Return type: None
-
removeEventListener(event, listener)[source]¶ Remove an event listener of this node.
The listener is removed only when both event type and listener is matched.
Return type: None
-