-
Notifications
You must be signed in to change notification settings - Fork 2
/
FrameworkToolAdmin.ts
50 lines (46 loc) · 1.41 KB
/
FrameworkToolAdmin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Tools
*/
import { Key } from "ts-key-enum";
import { ToolAdmin } from "@itwin/core-frontend";
import { UiFramework } from "../UiFramework";
/** Subclass of `ToolAdmin` in `@itwin/core-frontend` to be used to initialize `IModelApp`.
*
* Enable processing of shortcut keys registered to
* [[UiFramework.keyboardShortcuts]] when focus is set to Home.
*
* ```ts
* await IModelApp.startup({
* toolAdmin: new FrameworkToolAdmin()
* });
* ```
* @beta
*/
export class FrameworkToolAdmin extends ToolAdmin {
/** Process shortcut key events */
public override async processShortcutKey(
e: KeyboardEvent,
wentDown: boolean
): Promise<boolean> {
let handled = false;
if (wentDown && !UiFramework.isContextMenuOpen) {
if (
UiFramework.keyboardShortcuts.isFocusOnHome &&
e.key !== Key.Escape.valueOf()
) {
UiFramework.keyboardShortcuts.processKey(
e.key,
e.altKey,
e.ctrlKey,
e.shiftKey
);
handled = true;
}
}
return handled;
}
}