zng_ext_input::gesture

Struct GESTURES

source
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:

  1. The gestures manager receives a KEY_INPUT_EVENT in the event track, if a shortcut is completed it gets combined with any primed chords and become the shortcut that will cause the following actions:

  2. 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 and context_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.

  3. The app level SHORTCUT_EVENT is notified, with the list of actions that will run, app extensions can handle it before event to stop the resolved actions.

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

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

source

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.

Initial shortcuts are Enter and Space.

source

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.

source

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.

source

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.

source

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.

source

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§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> StateValue for T
where T: Any + Send + Sync,