feat(editors): support onKeyboardEvent & enableKeyboardShortcuts in sub-editors (#837)#840
Merged
Merged
Conversation
…ub-editors (#837) Keyboard handling previously only worked in the main editor: the `onKeyboardEvent` callback and `enableKeyboardShortcuts` option had no effect in sub-editors, so the crop-rotate `R`/`F` shortcuts could not be intercepted or disabled. - Move `onKeyboardEvent` into the shared `StandaloneEditorCallbacks` base (with a `handleKeyboardEvent` helper) so every standalone editor exposes it; `MainEditorCallbacks` now inherits it. - Centralize keyboard handling in `StandaloneEditorState`: it registers a single handler that respects `enableKeyboardShortcuts`, forwards to the editor's `onKeyboardEvent` and otherwise delegates to an overridable `onCustomKeyEvent` hook. - Crop-rotate and paint editors use the hook for their built-in shortcuts and expose a new `enableKeyboardShortcuts` config option (default true). - Filter, tune and blur editors forward keyboard events to their callbacks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #837
Problem
MainEditorCallbacks.onKeyboardEventandMainEditorConfigs.enableKeyboardShortcutsonly affected the main editor. In sub-editors there was no way to intercept or disable keyboard shortcuts — e.g. theR/Fkeys in the crop-rotate editor always triggered rotate/flip andonKeyboardEventwas never called.Changes
Shared callback (
onKeyboardEvent)onKeyboardEventinto the sharedStandaloneEditorCallbacksbase (plus ahandleKeyboardEventhelper). Every standalone editor's callbacks (crop-rotate, paint, filter, tune, blur) now exposes it, andMainEditorCallbacksinherits it (no behavior change for the main editor).Centralized handling (
StandaloneEditorState)enableKeyboardShortcutsisfalse,onKeyboardEvent(consumes it when that returnstrue),onCustomKeyEventhook for built-in shortcuts.Per-editor wiring
onCustomKeyEvent; their ownaddHandler/removeHandlerregistration was removed; newenableKeyboardShortcutsconfig option added (defaulttrue).Usage
Tests
Added a
Keyboard shortcutsgroup to the crop-rotate editor tests:Rrotates by default,enableKeyboardShortcuts: falseignores it, and anonKeyboardEventreturningtrueconsumes it (no rotation). Full suite (431 tests) passes anddart analyze libis clean.