Skip to main content

Shortcuts

Struct Shortcuts 

Source
pub struct Shortcuts {
    pub key: Option<KeyRef>,
    pub manager: Option<ShortcutManagerRef>,
    pub child: WidgetRef,
    pub debug_label: Option<String>,
    pub include_semantics: bool,
    /* private fields */
}
Expand description

A widget that creates key bindings to specific actions for its descendants.

This widget establishes a ShortcutManager to be used by its descendants when invoking an Action via a keyboard key combination that maps to an Intent.

This is similar to but more powerful than the CallbackShortcuts widget. Unlike CallbackShortcuts, this widget separates key bindings and their implementations. This separation allows Shortcuts to have key bindings that adapt to the focused context.

See also:

  • CallbackShortcuts, a simpler but less flexible widget that defines key bindings that invoke callbacks.
  • Intent, a trait for values containing a description of a user action to be invoked.
  • Action, a trait for defining an invocation of a user action.
  • CallbackAction, a class for creating an action from a callback.

Fields§

§key: Option<KeyRef>§manager: Option<ShortcutManagerRef>

The ShortcutManagerBase that will manage the mapping between key combinations and Actions.

If this widget was created with Shortcuts::manager, then ShortcutManagerBase::shortcuts will be used as the source for shortcuts. If Shortcuts::new is used, this manager will be None, and a default-constructed ShortcutManager will be used.

§child: WidgetRef

The widget below this widget in the tree.

§debug_label: Option<String>

The debug label that is printed for this node when logged.

If this label is set, then it will be displayed instead of the shortcut map when logged.

§include_semantics: bool

Whether to include semantics from Focus.

Defaults to true.

Implementations§

Source§

impl Shortcuts

Source

pub fn new<K>(shortcuts: ShortcutMap, child: impl IntoWidget<K>) -> Shortcuts

Creates a Shortcuts widget that owns the map of shortcuts and creates its own manager.

When using this constructor, manager is None.

See also:

Source

pub fn manager<K>( manager: ShortcutManagerRef, child: impl IntoWidget<K>, ) -> Shortcuts

Creates a Shortcuts widget that uses the manager to manage the map of shortcuts.

If this constructor is used, get_shortcuts will return the contents of ShortcutManagerBase::shortcuts.

Source

pub fn key(self, key: KeyRef) -> Shortcuts

Dart Shortcuts(key:).

Source

pub fn debug_label(self, debug_label: impl Into<String>) -> Shortcuts

Dart Shortcuts(debugLabel:).

Source

pub fn include_semantics(self, include_semantics: bool) -> Shortcuts

Dart Shortcuts(includeSemantics:).

Source

pub fn get_shortcuts(&self, app: &App) -> ShortcutMap

The map of shortcuts that describes the mapping between a key sequence defined by a ShortcutActivator and the Intent that will be emitted when that key sequence is pressed.

Trait Implementations§

Source§

impl Debug for Shortcuts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StatefulWidget for Shortcuts

Source§

type State = ShortcutsState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn create_state(&self) -> ShortcutsState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_check_constructor(&self)

Source§

fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Shortcuts

§

impl !Send for Shortcuts

§

impl !Sync for Shortcuts

§

impl !UnwindSafe for Shortcuts

§

impl Forget for Shortcuts

§

impl Freeze for Shortcuts
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, NonZero<u32>: Freeze, &'static ShortcutManagerVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<(Rc<dyn ShortcutActivator>, Rc<dyn Intent>)>: Freeze,

§

impl Move for Shortcuts

§

impl Unpin for Shortcuts
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, &'static ShortcutManagerVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn Widget>: Unpin, *const u8 is !null: Unpin, Rc<dyn ShortcutActivator>: Unpin, Rc<dyn Intent>: Unpin,

§

impl UnsafeUnpin for Shortcuts
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, &'static ShortcutManagerVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<(Rc<dyn ShortcutActivator>, Rc<dyn Intent>)>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>