Event API

class wdom.event.Event(type, init=None)[source]

Bases: object

Event 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]
stopPrapagation()[source]

Not implemented yet.

Return type:None
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:

Event

class wdom.event.EventListener(listener)[source]

Bases: object

Class 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: object

Base class for EventTargets.

This class and subclasses can add/remove event listeners and emit events.

ownerDocument

Need to check the target is mounted on document or not.

Return type:Optional[Node]
addEventListener(event, listener)[source]

Add event listener to this node.

event is a string which determines the event type when the new listener called. Acceptable events are same as JavaScript, without on. 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
on_event_pre(event)[source]

Run before dispatching events.

Used for seting values changed by user input, in some elements like input, textarea, or select. In this method, event.currentTarget is a dict sent from browser.

Return type:None
dispatchEvent(event)[source]

Emit events.

Return type:None