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_EVENT
in theevent
track, 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_shortcut
targeting a widget that is enabled and focused. - Command scoped in a widget that is enabled and focused.
- Contextual
click_shortcut
targeting 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_shortcut
targeting a widget that is in the focused window.focus_shortcut
targeting a widget that is enabled.- The
click_focused
andcontext_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_EVENT
is notified, with the list of actions that will run, app extensions can handle it beforeevent
to 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::starter
for 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.
Implementations§
source§impl GESTURES
impl GESTURES
sourcepub fn click_focused(&self) -> ArcVar<Shortcuts>
pub fn click_focused(&self) -> ArcVar<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) -> ArcVar<Shortcuts>
pub fn context_click_focused(&self) -> ArcVar<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) -> ArcVar<Duration>
pub fn shortcut_pressed_duration(&self) -> ArcVar<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