Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
OrbTk-mirror
OrbTk-mirror
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 61
    • Issues 61
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • redox-os
  • OrbTk-mirrorOrbTk-mirror
  • Issues
  • #73

Closed
Open
Opened Jan 14, 2018 by Jeremy Soller@jackpot51Owner

Rewrite of the system event system

Created by: FloVanGH

Here my suggestion for a new system event system:

Event capture

Events should be only captured by widgets, that are interested in the event. e.g. mouse events should be only propagate to widgets, that contains the current mouse position.

Propagation

Propagate events from root to leaf (tunnelling / preview events) and than back from leaf to root (bubbling). Events could be interrupted with event.handled = true.

http://csharphelper.com/blog/2015/03/understand-event-bubbling-and-tunneling-in-wpf-and-c/

Default set of event functions for system events

The widget trait should provide for each system event type (mouse, key, resize, ...) a separate function. The default implementation should do nothing. Each widget that is interested in a particular event could be override the corresponding function. After that there is no need to write complex event match statements in each widget.

Example

pub trait Widget {
    fn preview_mouse_down(event: MouseEvent) {}
    fn mouse_down(event: MouseEvent){}
    fn preview_key_pressed(event: KeyEvent) {}
    fn key_pressed(event: KeyEvent) {}
    ...
}

impl Widget for Button {
    fn mouse_down(event: MouseEvent) {
        // do something
        event.handled = true;
   }
}

Handled flag

Each event should provide a handled flag. If the flag is set to true the propagation of the event should stop. The flag should be set from the widget, that handles the event. This should be solve #44 (closed).

Additional

A combination with event aggregation or similar to handle custom "user" event should be possible.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: redox-os/orbtk-mirror#73