Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event capturing #614

Merged
merged 17 commits into from
Nov 14, 2020
Merged

Event capturing #614

merged 17 commits into from
Nov 14, 2020

Conversation

hecrj
Copy link
Member

@hecrj hecrj commented Nov 13, 2020

This PR allows widgets to inform the runtime about whether they have handled an event or not.

Specifically, a new event::Status enum has been introduced. It has two variants: Ignored and Captured, and Widget::on_event now must return one of them:

  • Captured if the event was handled by the implementor.
  • Ignored otherwise.

As a consequence, UserInterface::update has been changed to return an event::Status for every processed Event. This should help users that are integrating iced with their own custom event loop to implement proper event propagation (see #408 and #455).

Furthermore, subscription::Recipe in iced_native now takes a stream of (Event, event::Status) as input, effectively allowing subscriptions to discard events that have already been processed by a widget. This is specially useful for implementing global hotkeys (e.g. if a TextInput is focused, hotkeys will not trigger when typing on it).

Fixes #408.
Closes #455.

@hecrj hecrj added the feature New feature or request label Nov 13, 2020
@hecrj hecrj added this to the 0.2.0 milestone Nov 13, 2020
@hecrj hecrj self-assigned this Nov 13, 2020
@hecrj hecrj merged commit 62295f5 into master Nov 14, 2020
@hecrj hecrj deleted the feature/event-capturing branch November 14, 2020 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to integrate input events with existing engine, and use iced as ui library?
1 participant