Add isModifierActive helper function to actions with modifier mask.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
enum KeyModifiers {
|
||||
export enum KeyModifiers {
|
||||
leftCtrl = 1 << 0,
|
||||
leftShift = 1 << 1,
|
||||
leftAlt = 1 << 2,
|
||||
@@ -41,4 +41,8 @@ class KeystrokeModifiersAction extends KeyAction {
|
||||
toString(): string {
|
||||
return `<KeystrokeModifiersAction modifierMask="${this.modifierMask}">`;
|
||||
}
|
||||
|
||||
isModifierActive(modifier: KeyModifiers): boolean {
|
||||
return (this.modifierMask & modifier) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import {KeyModifiers} from './KeystrokeModifiersAction';
|
||||
|
||||
class KeystrokeWithModifiersAction extends KeyAction {
|
||||
|
||||
// @assertUInt8
|
||||
@@ -37,4 +39,8 @@ class KeystrokeWithModifiersAction extends KeyAction {
|
||||
toString(): string {
|
||||
return `<KeystrokeWithModifiersAction scancode="${this.scancode}" modifierMask="${this.modifierMask}">`;
|
||||
}
|
||||
|
||||
isModifierActive(modifier: KeyModifiers): boolean {
|
||||
return (this.modifierMask & modifier) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user