Add isModifierActive helper function to actions with modifier mask.

This commit is contained in:
József Farkas
2016-04-17 20:40:54 +02:00
parent d1f5e21e24
commit 25fa5535da
2 changed files with 11 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}