Event API¶
-
class
wdom.event.Event(type, init=None)[source]¶ Bases:
objectEvent interface class.
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]
-
-
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)[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, **kwargs)[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
-