EventHandler

Trait EventHandler 

Source
pub trait EventHandler {
    // Provided methods
    fn get_subscription(&mut self) -> Option<EVENT_GROUPS> { ... }
    fn attached(&mut self, root: HELEMENT) { ... }
    fn detached(&mut self, root: HELEMENT) { ... }
    fn document_complete(&mut self, root: HELEMENT, target: HELEMENT) { ... }
    fn document_close(&mut self, root: HELEMENT, target: HELEMENT) { ... }
    fn on_method_call(
        &mut self,
        root: HELEMENT,
        params: MethodParams<'_>,
    ) -> bool { ... }
    fn on_script_call(
        &mut self,
        root: HELEMENT,
        name: &str,
        args: &[Value],
    ) -> Option<Value> { ... }
    fn on_event(
        &mut self,
        root: HELEMENT,
        source: HELEMENT,
        target: HELEMENT,
        code: BEHAVIOR_EVENTS,
        phase: PHASE_MASK,
        reason: EventReason,
    ) -> bool { ... }
    fn on_timer(&mut self, root: HELEMENT, timer_id: u64) -> bool { ... }
    fn on_draw(
        &mut self,
        root: HELEMENT,
        gfx: HGFX,
        area: &RECT,
        layer: DRAW_EVENTS,
    ) -> bool { ... }
    fn on_size(&mut self, root: HELEMENT) { ... }
}
Expand description

DOM event handler which can be attached to any DOM element.

In notifications:

  • root means the DOM element to which we are attached (<html> for Window event handlers).
  • target contains a reference to the notification target DOM element.
  • source element e.g. in SELECTION_CHANGED it is the new selected <option>, in MENU_ITEM_CLICK it is a menu item (<li>) element.

For example, if we are attached to the <body> element, we will receive document_complete with target set to <html>.

Provided Methods§

Source

fn get_subscription(&mut self) -> Option<EVENT_GROUPS>

Return a list of event groups this event handler is subscribed to.

Default are HANDLE_BEHAVIOR_EVENT | HANDLE_SCRIPTING_METHOD_CALL | HANDLE_METHOD_CALL. See also default_events().

Source

fn attached(&mut self, root: HELEMENT)

Called when handler was attached to element or window. root is NULL if attaching to window without loaded document.

Subscription: always.

Source

fn detached(&mut self, root: HELEMENT)

Called when handler was detached from element or window.

Subscription: always.

Source

fn document_complete(&mut self, root: HELEMENT, target: HELEMENT)

Notification that document finishes its loading - all requests for external resources are finished.

Subscription: requires HANDLE_BEHAVIOR_EVENT, but will be sent only for the root element (<html>).

Source

fn document_close(&mut self, root: HELEMENT, target: HELEMENT)

The last notification before document removal from the DOM.

Subscription: requires HANDLE_BEHAVIOR_EVENT, but will be sent only for the root element (<html>).

Source

fn on_method_call(&mut self, root: HELEMENT, params: MethodParams<'_>) -> bool

Behavior method calls from script or other behaviors.

Return false to skip this event.

Subscription: requires HANDLE_METHOD_CALL.

Source

fn on_script_call( &mut self, root: HELEMENT, name: &str, args: &[Value], ) -> Option<Value>

Script calls from CSSS! script and TIScript.

Return None to skip this event.

Subscription: requires HANDLE_SCRIPTING_METHOD_CALL.

Source

fn on_event( &mut self, root: HELEMENT, source: HELEMENT, target: HELEMENT, code: BEHAVIOR_EVENTS, phase: PHASE_MASK, reason: EventReason, ) -> bool

Notification event from builtin behaviors.

Return false to skip this event.

Subscription: requires HANDLE_BEHAVIOR_EVENT.

Source

fn on_timer(&mut self, root: HELEMENT, timer_id: u64) -> bool

Timer event from attached element.

Return false to skip this event.

Subscription: requires HANDLE_TIMER.

Source

fn on_draw( &mut self, root: HELEMENT, gfx: HGFX, area: &RECT, layer: DRAW_EVENTS, ) -> bool

Drawing request event.

It allows to intercept drawing events of an Element and to manually draw its content, background and foreground layers.

Return false to skip this event.

Subscription: requires HANDLE_DRAW.

Source

fn on_size(&mut self, root: HELEMENT)

Size changed event.

Subscription: requires HANDLE_SIZE.

Implementors§