pub struct GESTURES;Expand description
Gesture events config service.
This service is provided by GestureManager.
§Shortcuts
This service coordinates shortcut associations with widgets and commands. To define a command’s shortcut use
the CommandShortcutExt methods. To define the shortcut that focus and clicks a widget use click_shortcut.
To define the shortcut that only focuses on a widget use focus_shortcut. To define a custom handle for a shortcut
use on_pre_event or on_event with the SHORTCUT_EVENT.
§Event Order
The same shortcut can end-up registered for multiple targets, activation of a shortcut causes these effects in this order:
-
The gestures manager receives a
KEY_INPUT_EVENTin theeventtrack, if a shortcut is completed it gets combined with any primed chords and become the shortcut that will cause the following actions: -
The click, command and focus shortcuts are resolved in this order:
First exclusively:
- Primary
click_shortcuttargeting a widget that is enabled and focused. - Command scoped in a widget that is enabled and focused.
- Contextual
click_shortcuttargeting a widget that is enabled and focused. - Primary, command scoped or contextual targeting a widget that is enabled and closest to the focused widget, child first (of the focused).
- Primary, command scoped or contextual targeting a widget that is enabled in the focused window.
- Primary, command scoped or contextual targeting a widget that is enabled.
focus_shortcuttargeting a widget that is in the focused window.focus_shortcuttargeting a widget that is enabled.- The
click_focusedandcontext_click_focused. - Same as the above, but for disabled widgets
And then:
a. All enabled commands targeting the focused window.
b. All enabled commands targeting the app.
- Primary
-
The app level
SHORTCUT_EVENTis notified, with the list of actions that will run, app extensions can handle it beforeeventto stop the resolved actions. -
The gestures manager receives the shortcut in
event, if propagation is not stopped and it contains any actions they are run, the click and command events are linked by the same propagation. If the shortcut contains no action and it -
If the shortcut is a
KeyChord::starterfor one of the registered shortcuts, and was not claimed by any of the above, the chord starter is primed for the next shortcut press.
The event propagation flag of shortcut, click and command events are linked, so stopping propagation in one signal
all others.
§Provider
This service is provided by the GestureManager extension, it will panic if used in an app not extended.
Implementations§
Source§impl GESTURES
impl GESTURES
Sourcepub fn click_focused(&self) -> Var<Shortcuts>
pub fn click_focused(&self) -> Var<Shortcuts>
Shortcuts that generate a primary CLICK_EVENT for the focused widget.
The shortcut only works if no widget or command claims it.
Clicks generated by this shortcut count as primary.
Sourcepub fn context_click_focused(&self) -> Var<Shortcuts>
pub fn context_click_focused(&self) -> Var<Shortcuts>
Shortcuts that generate a context CLICK_EVENT for the focused widget.
The shortcut only works if no widget or command claims it.
Clicks generated by this shortcut count as context.
Initial shortcut is ContextMenu.
Sourcepub fn shortcut_pressed_duration(&self) -> Var<Duration>
pub fn shortcut_pressed_duration(&self) -> Var<Duration>
When a shortcut or access primary click happens, targeted widgets can indicate that they are pressed for this duration.
Initial value is 50ms, set to 0 to deactivate this type of indication.
Sourcepub fn click_shortcut(
&self,
shortcuts: impl Into<Shortcuts>,
kind: ShortcutClick,
target: WidgetId,
) -> ShortcutsHandle
pub fn click_shortcut( &self, shortcuts: impl Into<Shortcuts>, kind: ShortcutClick, target: WidgetId, ) -> ShortcutsHandle
Register a widget to receive shortcut clicks when any of the shortcuts are pressed.
Sourcepub fn focus_shortcut(
&self,
shortcuts: impl Into<Shortcuts>,
target: WidgetId,
) -> ShortcutsHandle
pub fn focus_shortcut( &self, shortcuts: impl Into<Shortcuts>, target: WidgetId, ) -> ShortcutsHandle
Register a widget to receive keyboard focus when any of the shortcuts are pressed.
If the widget is not focusable the focus moves to the first focusable descendant or the first focusable ancestor.
Sourcepub fn shortcut_actions(&self, shortcut: Shortcut) -> ShortcutActions
pub fn shortcut_actions(&self, shortcut: Shortcut) -> ShortcutActions
Gets all the event notifications that are send if the shortcut was pressed at this moment.
See the struct level docs for details of how shortcut targets are resolved.
Auto Trait Implementations§
impl Freeze for GESTURES
impl RefUnwindSafe for GESTURES
impl Send for GESTURES
impl Sync for GESTURES
impl Unpin for GESTURES
impl UnwindSafe for GESTURES
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more