[][src]Trait sciter::dom::event::EventHandler

pub trait EventHandler {
    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) { ... } }

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

In notifications:

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

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

Provided methods

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

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

Default is HANDLE_BEHAVIOR_EVENT | HANDLE_SCRIPTING_METHOD_CALL. See also default_events().

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.

fn detached(&mut self, root: HELEMENT)

Called when handler was detached from element or window.

Subscription: always.

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>).

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>).

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.

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.

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.

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.

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.

fn on_size(&mut self, root: HELEMENT)

Size changed event.

Subscription: requires HANDLE_SIZE.

Loading content...

Implementors

Loading content...