forked from firka/flutter
Add actions and keyboard shortcut map support (#33298)
This implements the keyboard shortcut handling and action invocation in order to provide a place in the infrastructure for keyboard events to trigger actions. This will allow binding of key events to actions like "move the focus to the next widget" and "activate button".
This commit is contained in:
@@ -11,6 +11,19 @@
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// A base class for all keyboard key types.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [PhysicalKeyboardKey], a class with static values that describe the keys
|
||||
/// that are returned from [RawKeyEvent.physicalKey].
|
||||
/// * [LogicalKeyboardKey], a class with static values that describe the keys
|
||||
/// that are returned from [RawKeyEvent.logicalKey].
|
||||
abstract class KeyboardKey extends Diagnosticable {
|
||||
/// A const constructor so that subclasses may be const.
|
||||
const KeyboardKey();
|
||||
}
|
||||
|
||||
/// A class with static values that describe the keys that are returned from
|
||||
/// [RawKeyEvent.logicalKey].
|
||||
///
|
||||
@@ -108,7 +121,7 @@ import 'package:flutter/foundation.dart';
|
||||
/// to keyboard events.
|
||||
/// * [RawKeyboardListener], a widget used to listen to and supply handlers for
|
||||
/// keyboard events.
|
||||
class LogicalKeyboardKey extends Diagnosticable {
|
||||
class LogicalKeyboardKey extends KeyboardKey {
|
||||
/// Creates a LogicalKeyboardKey object with an optional key label and debug
|
||||
/// name.
|
||||
///
|
||||
@@ -249,6 +262,18 @@ class LogicalKeyboardKey extends Diagnosticable {
|
||||
/// for keys which are not recognized.
|
||||
static const int autogeneratedMask = 0x10000000000;
|
||||
|
||||
/// Mask for the synonym pseudo-keys generated for keys which appear in more
|
||||
/// than one place on the keyboard.
|
||||
///
|
||||
/// IDs in this range are used to represent keys which appear in multiple
|
||||
/// places on the keyboard, such as the SHIFT, ALT, CTRL, and numeric keypad
|
||||
/// keys. These key codes will never be generated by the key event system, but
|
||||
/// may be used in key maps to represent the union of all the keys of each
|
||||
/// type in order to match them.
|
||||
///
|
||||
/// To look up the synonyms that are defined, look in the [synonyms] map.
|
||||
static const int synonymMask = 0x20000000000;
|
||||
|
||||
/// The code prefix for keys which have a Unicode representation.
|
||||
///
|
||||
/// This is used by platform-specific code to generate Flutter key codes.
|
||||
@@ -362,7 +387,7 @@ class LogicalKeyboardKey extends Diagnosticable {
|
||||
/// to keyboard events.
|
||||
/// * [RawKeyboardListener], a widget used to listen to and supply handlers for
|
||||
/// keyboard events.
|
||||
class PhysicalKeyboardKey extends Diagnosticable {
|
||||
class PhysicalKeyboardKey extends KeyboardKey {
|
||||
/// Creates a PhysicalKeyboardKey object with an optional debug name.
|
||||
///
|
||||
/// The [usbHidUsage] must not be null.
|
||||
|
||||
Reference in New Issue
Block a user