pub trait ShortcutManagerBase:
ChangeNotifier
+ Sized
+ 'static {
// Required methods
fn shortcut_manager_data(
self: Handle<Self>,
app: &App,
) -> &ShortcutManagerData;
fn shortcut_manager_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut ShortcutManagerData;
// Provided methods
fn as_shortcut_manager(self: Handle<Self>) -> AnyShortcutManager { ... }
fn modal(self: Handle<Self>, app: &App) -> bool { ... }
fn set_modal(self: Handle<Self>, app: &mut App, modal: bool) { ... }
fn shortcuts(self: Handle<Self>, app: &App) -> ShortcutMap { ... }
fn set_shortcuts(self: Handle<Self>, app: &mut App, value: ShortcutMap) { ... }
fn indexed_shortcuts(
self: Handle<Self>,
app: &mut App,
) -> Rc<HashMap<Option<LogicalKeyboardKey>, Vec<ActivatorIntentPair>>> { ... }
fn find(
self: Handle<Self>,
app: &mut App,
event: &KeyEvent,
state: Handle<HardwareKeyboard>,
) -> Option<IntentRef> { ... }
fn handle_keypress(
self: Handle<Self>,
app: &mut App,
context: BuildContext,
event: &KeyEvent,
) -> KeyEventResult { ... }
}Expand description
The members Dart’s ShortcutManager declares, over a ShortcutManagerData bag.
Dart’s class is both instantiated (ShortcutManager) and subclassed (RadioGroup’s
manager ignores a key event while no radio in its group has focus), so the bodies live on
this trait and each Dart class is a leaf struct that implements it.
Required Methods§
Sourcefn shortcut_manager_data(self: Handle<Self>, app: &App) -> &ShortcutManagerData
fn shortcut_manager_data(self: Handle<Self>, app: &App) -> &ShortcutManagerData
Dart’s ShortcutManager fields, held under the field shortcut_manager
(shortcut_manager_accessors!).
Sourcefn shortcut_manager_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut ShortcutManagerData
fn shortcut_manager_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut ShortcutManagerData
Provided Methods§
Sourcefn as_shortcut_manager(self: Handle<Self>) -> AnyShortcutManager
fn as_shortcut_manager(self: Handle<Self>) -> AnyShortcutManager
This manager as the erased AnyShortcutManager — what to pass where a Dart API takes
a ShortcutManager.
Sourcefn modal(self: Handle<Self>, app: &App) -> bool
fn modal(self: Handle<Self>, app: &App) -> bool
True if the ShortcutManagerBase should not pass on keys that it doesn’t handle to
any key-handling widgets that are ancestors to this one.
Setting modal to true will prevent any key event given to this manager
from being given to any ancestor managers, even if that key doesn’t appear in the
shortcuts map.
The net effect of setting modal to true is to return
KeyEventResult::SkipRemainingHandlers from
handle_keypress if it does not exist in the shortcut map,
instead of returning KeyEventResult::Ignored.
Sourcefn shortcuts(self: Handle<Self>, app: &App) -> ShortcutMap
fn shortcuts(self: Handle<Self>, app: &App) -> ShortcutMap
Returns the shortcut map.
When the map is changed, listeners to this manager will be notified.
Sourcefn set_shortcuts(self: Handle<Self>, app: &mut App, value: ShortcutMap)
fn set_shortcuts(self: Handle<Self>, app: &mut App, value: ShortcutMap)
See shortcuts.
Sourcefn indexed_shortcuts(
self: Handle<Self>,
app: &mut App,
) -> Rc<HashMap<Option<LogicalKeyboardKey>, Vec<ActivatorIntentPair>>>
fn indexed_shortcuts( self: Handle<Self>, app: &mut App, ) -> Rc<HashMap<Option<LogicalKeyboardKey>, Vec<ActivatorIntentPair>>>
Dart’s ShortcutManager._indexedShortcuts.
Sourcefn find(
self: Handle<Self>,
app: &mut App,
event: &KeyEvent,
state: Handle<HardwareKeyboard>,
) -> Option<IntentRef>
fn find( self: Handle<Self>, app: &mut App, event: &KeyEvent, state: Handle<HardwareKeyboard>, ) -> Option<IntentRef>
Returns the Intent, if any, that matches the current set of pressed keys.
Returns None if no intent matches the current set of pressed keys.
Sourcefn handle_keypress(
self: Handle<Self>,
app: &mut App,
context: BuildContext,
event: &KeyEvent,
) -> KeyEventResult
fn handle_keypress( self: Handle<Self>, app: &mut App, context: BuildContext, event: &KeyEvent, ) -> KeyEventResult
Handles a key press event in the given context.
If a key mapping is found, then the associated action will be invoked using the Intent
activated by the ShortcutActivator in the shortcuts map, and the
currently focused widget’s context (from FocusManager::primary_focus).
Returns KeyEventResult::Handled if an action was invoked, otherwise
KeyEventResult::SkipRemainingHandlers if modal is true, or if it
maps to a DoNothingAction with consumes_key set to false, and in all other cases
returns KeyEventResult::Ignored.
In order for an action to be invoked (and KeyEventResult::Handled returned), a
ShortcutActivator must accept the given KeyEvent, be mapped to an Intent, the
Intent must be mapped to an Action, and the Action must be enabled.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".