[GH-ISSUE #997] [Improvement] Split shortcut events by function. #383

Closed
opened 2026-03-23 20:35:59 +00:00 by mirror · 2 comments
Owner

Originally created by @LucasXu0 on GitHub (Sep 7, 2022).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/997

Originally assigned to: @ChiragKr04 on GitHub.

Since #964 already supports distinguishing shortcut events based on different platforms.
We need to refactor the events previously triggered by RawKeyEvent to be triggered by Command

Example

Previous

ShortcutEventHandler pageUpDownHandler = (editorState, event) {
  if (event.logicalKey == LogicalKeyboardKey.pageUp) {
    // do the pageUp things.
    return KeyEventResult.handled;
  } else if (event.logicalKey == LogicalKeyboardKey.pageDown) {
    // do the pageDown things.
    return KeyEventResult.handled;
  }
  return KeyEventResult.ignored;
};

ShortcutEvent(
    key: 'page up / page down',
    command: 'page up,page down',
    handler: pageUpDownHandler,
),

After

ShortcutEventHandler pageUpEventHandler = (editorState, _) {
  // do the pageUp things.
}

ShortcutEventHandler pageDownEventHandler = (editorState, _) {
  // do the pageDown things.
}

ShortcutEvent(
    key: 'Page up',
    command: 'page up',
    handler: pageUpEventHandler,
),
ShortcutEvent(
    key: 'Page down',
    command: 'page down',
    handler: pageDownEventHandler,
),
Originally created by @LucasXu0 on GitHub (Sep 7, 2022). Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/997 Originally assigned to: @ChiragKr04 on GitHub. Since #964 already supports distinguishing shortcut events based on different platforms. We need to refactor the events previously triggered by `RawKeyEvent` to be triggered by `Command` ## Example **Previous** ```dart ShortcutEventHandler pageUpDownHandler = (editorState, event) { if (event.logicalKey == LogicalKeyboardKey.pageUp) { // do the pageUp things. return KeyEventResult.handled; } else if (event.logicalKey == LogicalKeyboardKey.pageDown) { // do the pageDown things. return KeyEventResult.handled; } return KeyEventResult.ignored; }; ShortcutEvent( key: 'page up / page down', command: 'page up,page down', handler: pageUpDownHandler, ), ``` **After** ```dart ShortcutEventHandler pageUpEventHandler = (editorState, _) { // do the pageUp things. } ShortcutEventHandler pageDownEventHandler = (editorState, _) { // do the pageDown things. } ShortcutEvent( key: 'Page up', command: 'page up', handler: pageUpEventHandler, ), ShortcutEvent( key: 'Page down', command: 'page down', handler: pageDownEventHandler, ), ```
Author
Owner

@ChiragKr04 commented on GitHub (Sep 8, 2022):

Can you assign me this?

<!-- gh-comment-id:1240954928 --> @ChiragKr04 commented on GitHub (Sep 8, 2022): Can you assign me this?
Author
Owner

@annieappflowy commented on GitHub (Sep 9, 2022):

Thanks @ChiragKr04 just assigned it to you

<!-- gh-comment-id:1242105602 --> @annieappflowy commented on GitHub (Sep 9, 2022): Thanks @ChiragKr04 just assigned it to you
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#383
No description provided.