@oxy.so/bloom 21.4.0 → 21.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/adoption-matrix.mdx +6 -6
- package/docs/agent-task-index.mdx +1 -0
- package/docs/dropdown-menu.mdx +11 -0
- package/docs/menubar.mdx +21 -0
- package/docs/platform-surface.mdx +11 -2
- package/docs/task-catalog.json +1 -1
- package/docs/task-catalog.mdx +1 -1
- package/lib/commonjs/dropdown-menu/DropdownMenu.js +86 -6
- package/lib/commonjs/dropdown-menu/DropdownMenu.js.map +1 -1
- package/lib/commonjs/dropdown-menu/context.js.map +1 -1
- package/lib/commonjs/floating/PopupPanel.js +17 -1
- package/lib/commonjs/floating/PopupPanel.js.map +1 -1
- package/lib/commonjs/floating/TriggerSlot.js +4 -0
- package/lib/commonjs/floating/TriggerSlot.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/kbd/chord.js +53 -0
- package/lib/commonjs/kbd/chord.js.map +1 -1
- package/lib/commonjs/menubar/declared.js +134 -11
- package/lib/commonjs/menubar/declared.js.map +1 -1
- package/lib/commonjs/menubar/description.js +37 -1
- package/lib/commonjs/menubar/description.js.map +1 -1
- package/lib/commonjs/menubar/registry.js +4 -1
- package/lib/commonjs/menubar/registry.js.map +1 -1
- package/lib/commonjs/menubar/use-held-modifiers.js +88 -0
- package/lib/commonjs/menubar/use-held-modifiers.js.map +1 -0
- package/lib/module/dropdown-menu/DropdownMenu.js +88 -6
- package/lib/module/dropdown-menu/DropdownMenu.js.map +1 -1
- package/lib/module/dropdown-menu/context.js.map +1 -1
- package/lib/module/floating/PopupPanel.js +17 -1
- package/lib/module/floating/PopupPanel.js.map +1 -1
- package/lib/module/floating/TriggerSlot.js +4 -0
- package/lib/module/floating/TriggerSlot.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/kbd/chord.js +50 -0
- package/lib/module/kbd/chord.js.map +1 -1
- package/lib/module/menubar/declared.js +137 -14
- package/lib/module/menubar/declared.js.map +1 -1
- package/lib/module/menubar/description.js +36 -3
- package/lib/module/menubar/description.js.map +1 -1
- package/lib/module/menubar/registry.js +4 -1
- package/lib/module/menubar/registry.js.map +1 -1
- package/lib/module/menubar/use-held-modifiers.js +81 -0
- package/lib/module/menubar/use-held-modifiers.js.map +1 -0
- package/lib/typescript/commonjs/dropdown-menu/DropdownMenu.d.ts +7 -1
- package/lib/typescript/commonjs/dropdown-menu/DropdownMenu.d.ts.map +1 -1
- package/lib/typescript/commonjs/dropdown-menu/context.d.ts +2 -0
- package/lib/typescript/commonjs/dropdown-menu/context.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/PopupPanel.d.ts +17 -4
- package/lib/typescript/commonjs/floating/PopupPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/TriggerSlot.d.ts +7 -1
- package/lib/typescript/commonjs/floating/TriggerSlot.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/kbd/chord.d.ts +19 -1
- package/lib/typescript/commonjs/kbd/chord.d.ts.map +1 -1
- package/lib/typescript/commonjs/menubar/declared.d.ts.map +1 -1
- package/lib/typescript/commonjs/menubar/description.d.ts +20 -0
- package/lib/typescript/commonjs/menubar/description.d.ts.map +1 -1
- package/lib/typescript/commonjs/menubar/registry.d.ts +5 -0
- package/lib/typescript/commonjs/menubar/registry.d.ts.map +1 -1
- package/lib/typescript/commonjs/menubar/types.d.ts +20 -0
- package/lib/typescript/commonjs/menubar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/menubar/use-held-modifiers.d.ts +7 -0
- package/lib/typescript/commonjs/menubar/use-held-modifiers.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform-surface/index.d.ts +1 -1
- package/lib/typescript/commonjs/platform-surface/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/platform-surface/types.d.ts +16 -5
- package/lib/typescript/commonjs/platform-surface/types.d.ts.map +1 -1
- package/lib/typescript/module/dropdown-menu/DropdownMenu.d.ts +7 -1
- package/lib/typescript/module/dropdown-menu/DropdownMenu.d.ts.map +1 -1
- package/lib/typescript/module/dropdown-menu/context.d.ts +2 -0
- package/lib/typescript/module/dropdown-menu/context.d.ts.map +1 -1
- package/lib/typescript/module/floating/PopupPanel.d.ts +17 -4
- package/lib/typescript/module/floating/PopupPanel.d.ts.map +1 -1
- package/lib/typescript/module/floating/TriggerSlot.d.ts +7 -1
- package/lib/typescript/module/floating/TriggerSlot.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +1 -1
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/kbd/chord.d.ts +19 -1
- package/lib/typescript/module/kbd/chord.d.ts.map +1 -1
- package/lib/typescript/module/menubar/declared.d.ts.map +1 -1
- package/lib/typescript/module/menubar/description.d.ts +20 -0
- package/lib/typescript/module/menubar/description.d.ts.map +1 -1
- package/lib/typescript/module/menubar/registry.d.ts +5 -0
- package/lib/typescript/module/menubar/registry.d.ts.map +1 -1
- package/lib/typescript/module/menubar/types.d.ts +20 -0
- package/lib/typescript/module/menubar/types.d.ts.map +1 -1
- package/lib/typescript/module/menubar/use-held-modifiers.d.ts +7 -0
- package/lib/typescript/module/menubar/use-held-modifiers.d.ts.map +1 -0
- package/lib/typescript/module/platform-surface/index.d.ts +1 -1
- package/lib/typescript/module/platform-surface/index.d.ts.map +1 -1
- package/lib/typescript/module/platform-surface/types.d.ts +16 -5
- package/lib/typescript/module/platform-surface/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dropdown-menu/DropdownMenu.tsx +94 -6
- package/src/dropdown-menu/context.ts +2 -0
- package/src/floating/PopupPanel.tsx +41 -2
- package/src/floating/TriggerSlot.tsx +10 -0
- package/src/index.ts +1 -0
- package/src/index.web.ts +1 -0
- package/src/kbd/chord.ts +52 -1
- package/src/menubar/declared.tsx +143 -13
- package/src/menubar/description.ts +42 -3
- package/src/menubar/registry.ts +9 -0
- package/src/menubar/types.ts +20 -0
- package/src/menubar/use-held-modifiers.ts +90 -0
- package/src/platform-surface/index.ts +1 -0
- package/src/platform-surface/types.ts +17 -5
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import { Fragment, isValidElement, type ReactNode } from 'react';
|
|
24
24
|
|
|
25
25
|
import { openHref } from '../hooks/link-activation';
|
|
26
|
-
import { type Chord, parseChord } from '../kbd/chord';
|
|
26
|
+
import { type Chord, modifiersText, parseChord, parseModifiers } from '../kbd/chord';
|
|
27
27
|
import type { PlatformEditAction, PlatformMenuAction } from '../platform-surface/types';
|
|
28
28
|
import type { MenuEntryKind } from './registry';
|
|
29
29
|
import { actionShortcut, isMenuAction } from './use-edit-action';
|
|
@@ -106,6 +106,8 @@ export interface DescribedEntry {
|
|
|
106
106
|
readonly checked?: boolean;
|
|
107
107
|
readonly keepOpen?: boolean;
|
|
108
108
|
readonly action?: PlatformMenuAction;
|
|
109
|
+
/** The modifiers that show it in place of the item before it (`MenuEntry.alternate`). */
|
|
110
|
+
readonly alternate?: string;
|
|
109
111
|
/** An editing action: its state and what choosing it does are the focused field's while one is. */
|
|
110
112
|
readonly editAction?: PlatformEditAction;
|
|
111
113
|
/** The element's own handler, as a press on its row would run it; undefined for none. */
|
|
@@ -140,6 +142,7 @@ interface ItemProps {
|
|
|
140
142
|
keepOpen?: boolean;
|
|
141
143
|
shortcut?: string;
|
|
142
144
|
action?: PlatformEditAction | PlatformMenuAction;
|
|
145
|
+
alternate?: string;
|
|
143
146
|
onPress?: () => void;
|
|
144
147
|
href?: string;
|
|
145
148
|
checked?: boolean;
|
|
@@ -149,7 +152,7 @@ interface ItemProps {
|
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
/** The children of a container as `DeclaredChildren` places them: one per place. */
|
|
152
|
-
function places(children: ReactNode): ReactNode[] {
|
|
155
|
+
export function places(children: ReactNode): ReactNode[] {
|
|
153
156
|
const out: ReactNode[] = [];
|
|
154
157
|
const visit = (node: ReactNode) => {
|
|
155
158
|
if (Array.isArray(node)) {
|
|
@@ -173,6 +176,39 @@ function chordOf(shortcut: string | undefined): Chord | null {
|
|
|
173
176
|
|
|
174
177
|
const keyOf = (path: readonly number[]) => `d${path.join('.')}`;
|
|
175
178
|
|
|
179
|
+
const isItem = (node: ReactNode) => isValidElement(node) && partOf(node.type) === 'item';
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* For each of a container's places (`places`), whether it is an ALTERNATE
|
|
183
|
+
* (`MenubarItemProps.alternate`): an item declaring modifiers that is placed
|
|
184
|
+
* right after an item (or after another alternate of one). The first item of
|
|
185
|
+
* the run is the one they are shown in place of. An empty place, a separator,
|
|
186
|
+
* a label or anything else breaks the run: an alternate after one is an
|
|
187
|
+
* ordinary item.
|
|
188
|
+
*/
|
|
189
|
+
export function alternatePlaces(nodes: readonly ReactNode[]): boolean[] {
|
|
190
|
+
let afterItem = false;
|
|
191
|
+
return nodes.map((node) => {
|
|
192
|
+
const alternate =
|
|
193
|
+
afterItem &&
|
|
194
|
+
isValidElement<ItemProps>(node) &&
|
|
195
|
+
isItem(node) &&
|
|
196
|
+
alternateOf(node.props.alternate).alternate !== undefined;
|
|
197
|
+
afterItem = isItem(node);
|
|
198
|
+
return alternate;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* An item's `alternate` as an entry carries it: its modifiers in their canonical spelling; nothing
|
|
204
|
+
* when it has none, or declares none that are modifiers (the mounted row warns once).
|
|
205
|
+
*/
|
|
206
|
+
export function alternateOf(alternate: string | undefined): { alternate?: string } {
|
|
207
|
+
if (alternate === undefined) return {};
|
|
208
|
+
const modifiers = parseModifiers(alternate);
|
|
209
|
+
return modifiers ? { alternate: modifiersText(modifiers) } : {};
|
|
210
|
+
}
|
|
211
|
+
|
|
176
212
|
/**
|
|
177
213
|
* `children`'s description: its entries, each at `[...path, place]` under
|
|
178
214
|
* `parentKey`, and what it could not read.
|
|
@@ -187,7 +223,9 @@ export function describeMenu(children: ReactNode): MenuDescription {
|
|
|
187
223
|
parentKey: string | null,
|
|
188
224
|
radio: RadioSelection | null,
|
|
189
225
|
) => {
|
|
190
|
-
places(nodes)
|
|
226
|
+
const placed = places(nodes);
|
|
227
|
+
const alternates = alternatePlaces(placed);
|
|
228
|
+
placed.forEach((node, place) => {
|
|
191
229
|
const at = [...path, place];
|
|
192
230
|
if (node === null || node === undefined || typeof node === 'boolean') return;
|
|
193
231
|
if (!isValidElement<ItemProps>(node)) {
|
|
@@ -219,6 +257,7 @@ export function describeMenu(children: ReactNode): MenuDescription {
|
|
|
219
257
|
keepOpen: props.keepOpen ?? false,
|
|
220
258
|
...(menuAction ? { action: menuAction } : null),
|
|
221
259
|
...(editAction ? { editAction } : null),
|
|
260
|
+
...(alternates[place] ? alternateOf(props.alternate) : null),
|
|
222
261
|
run: handler,
|
|
223
262
|
runs: true,
|
|
224
263
|
});
|
package/src/menubar/registry.ts
CHANGED
|
@@ -47,6 +47,11 @@ export interface MenuEntry {
|
|
|
47
47
|
readonly keepOpen?: boolean;
|
|
48
48
|
/** The application's standard command it is (About, Settings…), for the platform's bar. */
|
|
49
49
|
readonly action?: PlatformMenuAction;
|
|
50
|
+
/**
|
|
51
|
+
* The modifiers that show it in place of the item before it (`MenubarItemProps.alternate`),
|
|
52
|
+
* spelled as `modifiersText` does. A platform's bar shows the item, not its alternate.
|
|
53
|
+
*/
|
|
54
|
+
readonly alternate?: string;
|
|
50
55
|
/** Runs the item as a press on its row would. Commands only. */
|
|
51
56
|
readonly run?: () => void;
|
|
52
57
|
}
|
|
@@ -80,6 +85,7 @@ function sameEntry(a: MenuEntry, b: MenuEntry): boolean {
|
|
|
80
85
|
a.checked === b.checked &&
|
|
81
86
|
a.keepOpen === b.keepOpen &&
|
|
82
87
|
a.action === b.action &&
|
|
88
|
+
a.alternate === b.alternate &&
|
|
83
89
|
a.run === b.run
|
|
84
90
|
);
|
|
85
91
|
}
|
|
@@ -163,7 +169,10 @@ export class MenubarRegistry {
|
|
|
163
169
|
items: this.describeItems(entry.id, live),
|
|
164
170
|
},
|
|
165
171
|
];
|
|
172
|
+
// The platform's menus have no alternates: the item is shown, and the alternate's
|
|
173
|
+
// shortcut runs it from Bloom's keys (`shortcutFor`).
|
|
166
174
|
case 'item':
|
|
175
|
+
if (entry.alternate !== undefined) return [];
|
|
167
176
|
return [
|
|
168
177
|
{
|
|
169
178
|
kind: 'item',
|
package/src/menubar/types.ts
CHANGED
|
@@ -125,6 +125,26 @@ export interface MenubarItemProps extends MenuRowProps, MenubarShortcutProp {
|
|
|
125
125
|
* Its shortcut runs it on every platform, as any item's does.
|
|
126
126
|
*/
|
|
127
127
|
action?: PlatformEditAction | PlatformMenuAction;
|
|
128
|
+
/**
|
|
129
|
+
* Makes the item the ALTERNATE of the item declared just before it, shown in
|
|
130
|
+
* its place while exactly these modifiers are held (`Alt`, `Alt+Shift`,
|
|
131
|
+
* `Mod+Alt`: a chord's modifier names), as a Mac's `isAlternate` item with
|
|
132
|
+
* its `keyEquivalentModifierMask`: Option turns Restart… into Restart, a
|
|
133
|
+
* command that asks no question. Several alternates in a row each replace
|
|
134
|
+
* the first item before them that is not one, with their own modifiers.
|
|
135
|
+
*
|
|
136
|
+
* The two are one row of the open menu: it shows the alternate the instant
|
|
137
|
+
* its modifiers go down and the item again as they go up (the platform's
|
|
138
|
+
* `keyboard.subscribeModifiers`, its key presses, or the document's keys and
|
|
139
|
+
* pointer on the web), and keeps its place and highlight as it swaps. Each
|
|
140
|
+
* keeps its own label, state, handler and `shortcut`, and each shortcut runs
|
|
141
|
+
* its own item whether the menu is open or closed, and whichever is shown.
|
|
142
|
+
* An alternate with no item before it (first in its menu or group, or after
|
|
143
|
+
* a separator or a label) is an ordinary item. Where the platform draws the
|
|
144
|
+
* bar (`menu-bar`), the platform's menus show the item; the alternate's
|
|
145
|
+
* shortcut still runs it.
|
|
146
|
+
*/
|
|
147
|
+
alternate?: string;
|
|
128
148
|
}
|
|
129
149
|
export interface MenubarCheckboxItemProps extends MenuCheckboxRowProps, MenubarShortcutProp {}
|
|
130
150
|
export type MenubarRadioGroupProps = MenuRadioGroupProps;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The modifier keys held, followed while an open menu shows an item with an
|
|
3
|
+
* alternate (`MenubarItemProps.alternate`), as a Mac's menu follows the flags
|
|
4
|
+
* to swap an item for its alternate the instant Option goes down or up.
|
|
5
|
+
*
|
|
6
|
+
* WHERE THEY COME FROM:
|
|
7
|
+
* - the platform's `keyboard`: its `subscribeModifiers` (each change, and
|
|
8
|
+
* those held as the window takes the keyboard), and each key press's flags
|
|
9
|
+
* (a modifier's own press holds it), for a platform that tells no changes;
|
|
10
|
+
* - otherwise the document (the web): each key going down or up, and the
|
|
11
|
+
* pointer's flags as it moves or presses, so a menu opened with Option held
|
|
12
|
+
* shows its alternates as soon as the pointer moves; the window losing
|
|
13
|
+
* focus releases them all;
|
|
14
|
+
* - otherwise none: no modifier is ever held.
|
|
15
|
+
*/
|
|
16
|
+
import { useEffect, useState } from 'react';
|
|
17
|
+
|
|
18
|
+
import { usePlatformKeyboard } from '../platform-surface/context';
|
|
19
|
+
import type { PlatformKeyEvent, PlatformModifiers } from '../platform-surface/types';
|
|
20
|
+
|
|
21
|
+
export const NO_MODIFIERS: PlatformModifiers = {
|
|
22
|
+
altKey: false,
|
|
23
|
+
ctrlKey: false,
|
|
24
|
+
metaKey: false,
|
|
25
|
+
shiftKey: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** The flags a key press leaves held: its own, and its key when the key is a modifier. */
|
|
29
|
+
export function modifiersOfKey(event: PlatformKeyEvent): PlatformModifiers {
|
|
30
|
+
return {
|
|
31
|
+
altKey: event.altKey || event.key === 'Alt',
|
|
32
|
+
ctrlKey: event.ctrlKey || event.key === 'Control',
|
|
33
|
+
metaKey: event.metaKey || event.key === 'Meta',
|
|
34
|
+
shiftKey: event.shiftKey || event.key === 'Shift',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const sameModifiers = (a: PlatformModifiers, b: PlatformModifiers) =>
|
|
39
|
+
a.altKey === b.altKey &&
|
|
40
|
+
a.ctrlKey === b.ctrlKey &&
|
|
41
|
+
a.metaKey === b.metaKey &&
|
|
42
|
+
a.shiftKey === b.shiftKey;
|
|
43
|
+
|
|
44
|
+
const flagsOf = (event: PlatformModifiers): PlatformModifiers => ({
|
|
45
|
+
altKey: !!event.altKey,
|
|
46
|
+
ctrlKey: !!event.ctrlKey,
|
|
47
|
+
metaKey: !!event.metaKey,
|
|
48
|
+
shiftKey: !!event.shiftKey,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The modifiers held now, while the calling component is mounted. */
|
|
52
|
+
export function useHeldModifiers(): PlatformModifiers {
|
|
53
|
+
const keyboard = usePlatformKeyboard();
|
|
54
|
+
const [held, setHeld] = useState(NO_MODIFIERS);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const hold = (next: PlatformModifiers) =>
|
|
58
|
+
setHeld((was) => (sameModifiers(was, next) ? was : next));
|
|
59
|
+
if (keyboard) {
|
|
60
|
+
const changes = keyboard.subscribeModifiers?.((flags) => hold(flagsOf(flags)));
|
|
61
|
+
const presses = keyboard.subscribe((event) => {
|
|
62
|
+
hold(modifiersOfKey(event));
|
|
63
|
+
return false;
|
|
64
|
+
});
|
|
65
|
+
return () => {
|
|
66
|
+
changes?.();
|
|
67
|
+
presses();
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (typeof document === 'undefined' || typeof window === 'undefined') return undefined;
|
|
71
|
+
// A key going down carries its own modifier's flag, and going up drops it (W3C).
|
|
72
|
+
const onKey = (event: KeyboardEvent) => hold(flagsOf(event));
|
|
73
|
+
const onPointer = (event: PointerEvent) => hold(flagsOf(event));
|
|
74
|
+
const onBlur = () => hold(NO_MODIFIERS);
|
|
75
|
+
document.addEventListener('keydown', onKey, true);
|
|
76
|
+
document.addEventListener('keyup', onKey, true);
|
|
77
|
+
document.addEventListener('pointermove', onPointer, true);
|
|
78
|
+
document.addEventListener('pointerdown', onPointer, true);
|
|
79
|
+
window.addEventListener('blur', onBlur);
|
|
80
|
+
return () => {
|
|
81
|
+
document.removeEventListener('keydown', onKey, true);
|
|
82
|
+
document.removeEventListener('keyup', onKey, true);
|
|
83
|
+
document.removeEventListener('pointermove', onPointer, true);
|
|
84
|
+
document.removeEventListener('pointerdown', onPointer, true);
|
|
85
|
+
window.removeEventListener('blur', onBlur);
|
|
86
|
+
};
|
|
87
|
+
}, [keyboard]);
|
|
88
|
+
|
|
89
|
+
return held;
|
|
90
|
+
}
|
|
@@ -461,19 +461,23 @@ export interface PlatformMenuBar {
|
|
|
461
461
|
onActivate(listener: (id: string) => void): () => void;
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
+
/** The modifier keys held: W3C `KeyboardEvent`'s and `PointerEvent`'s flags. */
|
|
465
|
+
export interface PlatformModifiers {
|
|
466
|
+
readonly altKey: boolean;
|
|
467
|
+
readonly ctrlKey: boolean;
|
|
468
|
+
readonly metaKey: boolean;
|
|
469
|
+
readonly shiftKey: boolean;
|
|
470
|
+
}
|
|
471
|
+
|
|
464
472
|
/**
|
|
465
473
|
* A key press as the platform reports it: W3C `KeyboardEvent`'s fields, the
|
|
466
474
|
* shape React Native's own key events carry.
|
|
467
475
|
*/
|
|
468
|
-
export interface PlatformKeyEvent {
|
|
476
|
+
export interface PlatformKeyEvent extends PlatformModifiers {
|
|
469
477
|
/** `KeyboardEvent.key`: `n`, `N`, `Enter`, `ArrowDown`, … */
|
|
470
478
|
readonly key: string;
|
|
471
479
|
/** `KeyboardEvent.code`, the physical key (`KeyN`), when the platform knows it. */
|
|
472
480
|
readonly code?: string;
|
|
473
|
-
readonly altKey: boolean;
|
|
474
|
-
readonly ctrlKey: boolean;
|
|
475
|
-
readonly metaKey: boolean;
|
|
476
|
-
readonly shiftKey: boolean;
|
|
477
481
|
/** Held down and repeating. */
|
|
478
482
|
readonly repeat?: boolean;
|
|
479
483
|
/** Part of an input method's composition. */
|
|
@@ -494,6 +498,14 @@ export interface PlatformKeyboard {
|
|
|
494
498
|
* then does not deliver it to the focused view. Returns the unsubscribe.
|
|
495
499
|
*/
|
|
496
500
|
subscribe(listener: (event: PlatformKeyEvent) => boolean): () => void;
|
|
501
|
+
/**
|
|
502
|
+
* Calls `listener` with the modifiers held each time they change, as a Mac's
|
|
503
|
+
* `flagsChanged:`, and with those held as the window takes the keyboard.
|
|
504
|
+
* Optional: an open menu shows an item's alternate (`MenubarItemProps`'
|
|
505
|
+
* `alternate`) the instant Option goes down or up with it, and without it
|
|
506
|
+
* only as a key is pressed with Option held. Returns the unsubscribe.
|
|
507
|
+
*/
|
|
508
|
+
subscribeModifiers?(listener: (held: PlatformModifiers) => void): () => void;
|
|
497
509
|
}
|
|
498
510
|
|
|
499
511
|
/**
|