pub struct CallbackShortcuts {
pub key: Option<KeyRef>,
pub bindings: Vec<(ShortcutActivatorRef, Listener)>,
pub child: WidgetRef,
}Expand description
A widget that binds key combinations to specific callbacks.
This is similar to but simpler than the Shortcuts widget as it doesn’t require Intents
and Actions widgets. Instead, it accepts a map of ShortcutActivators to callbacks.
Unlike Shortcuts, this widget does not separate key bindings and their implementations.
That separation allows Shortcuts to have key bindings that adapt to the focused context.
See also:
Shortcuts, a more powerful widget for defining key bindings.Focus, a widget that defines which widgets can receive keyboard focus.
Fields§
§key: Option<KeyRef>See Widget::key.
bindings: Vec<(ShortcutActivatorRef, Listener)>A map of key combinations to callbacks used to define the shortcut bindings.
If a descendant of this widget has focus, and a key is pressed, the activator keys of this map will be asked if they accept the key event. If they do, then the corresponding callback is invoked, and the key event propagation is halted. If none of the activators accept the key event, then the key event continues to be propagated up the focus chain.
If more than one activator accepts the key event, then all of the callbacks associated with activators that accept the key event are invoked.
child: WidgetRefThe widget below this widget in the tree.
Implementations§
Source§impl CallbackShortcuts
impl CallbackShortcuts
Sourcepub fn new<K>(
bindings: Vec<(ShortcutActivatorRef, Listener)>,
child: impl IntoWidget<K>,
) -> CallbackShortcuts
pub fn new<K>( bindings: Vec<(ShortcutActivatorRef, Listener)>, child: impl IntoWidget<K>, ) -> CallbackShortcuts
Creates a CallbackShortcuts widget.
Sourcepub fn key(self, key: KeyRef) -> CallbackShortcuts
pub fn key(self, key: KeyRef) -> CallbackShortcuts
Dart CallbackShortcuts(key:).
Trait Implementations§
Source§impl Debug for CallbackShortcuts
impl Debug for CallbackShortcuts
Source§impl StatelessWidget for CallbackShortcuts
impl StatelessWidget for CallbackShortcuts
Source§fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef
fn build(&self, _app: &mut App, _context: BuildContext) -> WidgetRef
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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 debug_check_constructor(&self)
fn debug_check_constructor(&self)
Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
this is PreferredSizeWidget: a widget that implements PreferredSizeWidget
answers with itself, which is what a parent asking an erased child for its preferred
size reads.Auto Trait Implementations§
impl !RefUnwindSafe for CallbackShortcuts
impl !Send for CallbackShortcuts
impl !Sync for CallbackShortcuts
impl !UnwindSafe for CallbackShortcuts
impl Forget for CallbackShortcuts
impl Freeze for CallbackShortcutswhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(Rc<dyn ShortcutActivator>, Listener)>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
impl Move for CallbackShortcuts
impl Unpin for CallbackShortcuts
impl UnsafeUnpin for CallbackShortcutswhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(Rc<dyn ShortcutActivator>, Listener)>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.