| Description | Hierarchy | Fields | Methods | Properties |
type TInputShortcut = class(TObject)
An input shortcut represents a keyboard and/or mouse shortcut for some command. Up to two key shortcuts may be assigned to a single item, and one mouse shortcut, and one character shortcut.
Normal "key shortcut" is identified by Keys.TKey value.
"Character shortcut" differs from "key shortcut" because it's identified by produced character. We don't deal here how this character is produced (for example, character "X" may produced on normal systems by Shift + "x" or by pressing "x" while "caps lock" is on; but this is not dealt with in this unit (it's usually provided by operating system / GUI toolkit to GLWindow unit), we just get characters passed to TMatrixNavigator.KeyDown and such methods.)
![]() |
procedure Changed; virtual; |
![]() |
constructor Create(AKey1: TKey; AKey2: TKey; ACharacter: Char; AMouseButtonUse: boolean; AMouseButton: TMouseButton); |
![]() |
procedure MakeDefault; |
![]() |
procedure AssignFromDefault(Source: TInputShortcut); |
![]() |
procedure Assign(Source: TInputShortcut; CopyDefaults: boolean); |
![]() |
procedure MakeClear; |
![]() |
function IsPressed(KeysDown: PKeysBooleans; CharactersDown: PCharactersBooleans; const MousePressed: TMouseButtons): boolean; |
![]() |
function IsKey(Key: TKey; ACharacter: Char): boolean; |
![]() |
function IsMouseButton(AMouseButton: TMouseButton): boolean; |
![]() |
function IsEvent(MouseEvent: boolean; Key: TKey; ACharacter: Char; AMouseButton: TMouseButton): boolean; |
![]() |
function Description(const NoneString: string): string; |
![]() |
property Key1: TKey read FKey1 write SetKey1; |
![]() |
property Key2: TKey read FKey2 write SetKey2; |
![]() |
property Character: Char read FCharacter write SetCharacter; |
![]() |
property MouseButtonUse: boolean read FMouseButtonUse write SetMouseButtonUse; |
![]() |
property MouseButton: TMouseButton read FMouseButton write SetMouseButton; |
![]() |
property DefaultKey1: TKey read FDefaultKey1 write FDefaultKey1; |
![]() |
property DefaultKey2: TKey read FDefaultKey2 write FDefaultKey2; |
![]() |
property DefaultCharacter: Char
read FDefaultCharacter write FDefaultCharacter; |
![]() |
property DefaultMouseButtonUse: boolean
read FDefaultMouseButtonUse write FDefaultMouseButtonUse; |
![]() |
property DefaultMouseButton: TMouseButton
read FDefaultMouseButton write FDefaultMouseButton; |
![]() |
property OnChanged: TInputShortcutChangedFunc
read FOnChanged write FOnChanged; |
![]() |
procedure Changed; virtual; |
![]() |
constructor Create(AKey1: TKey; AKey2: TKey; ACharacter: Char; AMouseButtonUse: boolean; AMouseButton: TMouseButton); |
|
Constructor. Key/mouse shortcuts passed here are interpreted as the default shortcuts (so they will be used in subsequent MakeDefault) and they are also the initial values for Key1, Key2 etc. properties. | |
![]() |
procedure MakeDefault; |
![]() |
procedure AssignFromDefault(Source: TInputShortcut); |
|
This assigns to this object the default values from Source. | |
![]() |
procedure Assign(Source: TInputShortcut; CopyDefaults: boolean); |
|
This copies Source properties to this object. It always copies "current" properties (Key1, Key2, Character, MouseButtonUse, MouseButton), and optionally (if CopyDefaults) also copies the DefaultXxx properties. | |
![]() |
procedure MakeClear; |
|
This sets both keys to K_None, Character to #0 and MouseButtonUse to | |
![]() |
function IsPressed(KeysDown: PKeysBooleans; CharactersDown: PCharactersBooleans; const MousePressed: TMouseButtons): boolean; |
|
Given a set of currently pressed keys and mouse buttons, decide whether this input is currently pressed. You can pass Analogously, you can pass | |
![]() |
function IsKey(Key: TKey; ACharacter: Char): boolean; |
|
Check does given Key or ACharacter correspond to this input shortcut. If Key = K_None and ACharacter = #0, result is always | |
![]() |
function IsMouseButton(AMouseButton: TMouseButton): boolean; |
|
Check does given mouse button correspond to this input shortcut. In practice, just checks MouseButtonUse and if | |
![]() |
function IsEvent(MouseEvent: boolean; Key: TKey; ACharacter: Char; AMouseButton: TMouseButton): boolean; |
|
Check does given key/character (if not MouseEvent) or mouse button (if MouseEvent) correspond to this input shortcut. Basically, this is a "dispatcher" that simply calls IsKey or IsMouseButton method. Depending on the MouseEvent value, some of the other parameters (Key/ACharacter or AMouseButton) are simply ignored. This is often comfortable method if you want to squeeze calling IsKey and IsMouseButton into one procedure in the implementation — see e.g. TMatrixWalker.EventDown. | |
![]() |
function Description(const NoneString: string): string; |
|
Describe this input shortcut. If it's not active at all (like after MakeClear), we will use NoneString. | |
![]() |
property Key1: TKey read FKey1 write SetKey1; |
|
Key shortcuts for given command. You can set any of them to K_None to indicate that no key is assigned. | |
![]() |
property Key2: TKey read FKey2 write SetKey2; |
![]() |
property Character: Char read FCharacter write SetCharacter; |
|
| |
![]() |
property MouseButtonUse: boolean read FMouseButtonUse write SetMouseButtonUse; |
|
Mouse shortcut for given command. You can set | |
![]() |
property MouseButton: TMouseButton read FMouseButton write SetMouseButton; |
![]() |
property DefaultKey1: TKey read FDefaultKey1 write FDefaultKey1; |
|
Default values for properties key/mouse. You can change them — this will change what MakeDefault does. Note that setting these properties doesn't automatically set corresponding "current" property. E.g. | |
![]() |
property DefaultKey2: TKey read FDefaultKey2 write FDefaultKey2; |
![]() |
property DefaultCharacter: Char
read FDefaultCharacter write FDefaultCharacter; |
![]() |
property DefaultMouseButtonUse: boolean
read FDefaultMouseButtonUse write FDefaultMouseButtonUse; |
![]() |
property DefaultMouseButton: TMouseButton
read FDefaultMouseButton write FDefaultMouseButton; |
![]() |
property OnChanged: TInputShortcutChangedFunc
read FOnChanged write FOnChanged; |
|
If assigned, this will be called always right after the key/character/mouse shortcut value changed. Note that this is called only when the "current" values (Key1, Key2, Character, MouseButtonUse, MouseButton) changed, and it's not called when just the DefaultXxx values changed. | |