(waveEvent: WaveKeyboardEvent)
| 414 | } |
| 415 | |
| 416 | function appHandleKeyDown(waveEvent: WaveKeyboardEvent): boolean { |
| 417 | if (globalKeybindingsDisabled) { |
| 418 | return false; |
| 419 | } |
| 420 | const nativeEvent = (waveEvent as any).nativeEvent; |
| 421 | if (lastHandledEvent != null && nativeEvent != null && lastHandledEvent === nativeEvent) { |
| 422 | return false; |
| 423 | } |
| 424 | lastHandledEvent = nativeEvent; |
| 425 | if (activeChord) { |
| 426 | console.log("handle activeChord", activeChord); |
| 427 | // If we're in chord mode, look for the second key. |
| 428 | const chordBindings = globalChordMap.get(activeChord); |
| 429 | const [, handler] = checkKeyMap(waveEvent, chordBindings); |
| 430 | if (handler) { |
| 431 | resetChord(); |
| 432 | return handler(waveEvent); |
| 433 | } else { |
| 434 | // invalid chord; reset state and consume key |
| 435 | resetChord(); |
| 436 | return true; |
| 437 | } |
| 438 | } |
| 439 | const [chordKeyMatch] = checkKeyMap(waveEvent, globalChordMap); |
| 440 | if (chordKeyMatch) { |
| 441 | setActiveChord(chordKeyMatch); |
| 442 | return true; |
| 443 | } |
| 444 | |
| 445 | const [, globalHandler] = checkKeyMap(waveEvent, globalKeyMap); |
| 446 | if (globalHandler) { |
| 447 | const handled = globalHandler(waveEvent); |
| 448 | if (handled) { |
| 449 | return true; |
| 450 | } |
| 451 | } |
| 452 | if (isTabWindow()) { |
| 453 | const layoutModel = getLayoutModelForStaticTab(); |
| 454 | const focusedNode = globalStore.get(layoutModel.focusedNode); |
| 455 | const blockId = focusedNode?.data?.blockId; |
| 456 | if (blockId != null && shouldDispatchToBlock(waveEvent)) { |
| 457 | const bcm = getBlockComponentModel(blockId); |
| 458 | const viewModel = bcm?.viewModel; |
| 459 | if (viewModel?.keyDownHandler) { |
| 460 | const handledByBlock = viewModel.keyDownHandler(waveEvent); |
| 461 | if (handledByBlock) { |
| 462 | return true; |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | return false; |
| 468 | } |
| 469 | |
| 470 | function registerControlShiftStateUpdateHandler() { |
| 471 | getApi().onControlShiftStateUpdate((state: boolean) => { |
no test coverage detected