mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: splited shortcut event functions
This commit is contained in:
parent
944b2d97cd
commit
7b06b4c427
@ -2,21 +2,20 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:appflowy_editor/src/service/shortcut_event/shortcut_event_handler.dart';
|
import 'package:appflowy_editor/src/service/shortcut_event/shortcut_event_handler.dart';
|
||||||
|
|
||||||
ShortcutEventHandler pageUpDownHandler = (editorState, event) {
|
ShortcutEventHandler pageUpHandler = (editorState, _) {
|
||||||
if (event.logicalKey == LogicalKeyboardKey.pageUp) {
|
final scrollHeight = editorState.service.scrollService?.onePageHeight;
|
||||||
final scrollHeight = editorState.service.scrollService?.onePageHeight;
|
final scrollService = editorState.service.scrollService;
|
||||||
final scrollService = editorState.service.scrollService;
|
if (scrollHeight != null && scrollService != null) {
|
||||||
if (scrollHeight != null && scrollService != null) {
|
scrollService.scrollTo(scrollService.dy - scrollHeight);
|
||||||
scrollService.scrollTo(scrollService.dy - scrollHeight);
|
|
||||||
}
|
|
||||||
return KeyEventResult.handled;
|
|
||||||
} else if (event.logicalKey == LogicalKeyboardKey.pageDown) {
|
|
||||||
final scrollHeight = editorState.service.scrollService?.onePageHeight;
|
|
||||||
final scrollService = editorState.service.scrollService;
|
|
||||||
if (scrollHeight != null && scrollService != null) {
|
|
||||||
scrollService.scrollTo(scrollService.dy + scrollHeight);
|
|
||||||
}
|
|
||||||
return KeyEventResult.handled;
|
|
||||||
}
|
}
|
||||||
return KeyEventResult.ignored;
|
return KeyEventResult.handled;
|
||||||
|
};
|
||||||
|
|
||||||
|
ShortcutEventHandler pageDownHandler = (editorState, _) {
|
||||||
|
final scrollHeight = editorState.service.scrollService?.onePageHeight;
|
||||||
|
final scrollService = editorState.service.scrollService;
|
||||||
|
if (scrollHeight != null && scrollService != null) {
|
||||||
|
scrollService.scrollTo(scrollService.dy + scrollHeight);
|
||||||
|
}
|
||||||
|
return KeyEventResult.handled;
|
||||||
};
|
};
|
||||||
|
@ -196,8 +196,13 @@ List<ShortcutEvent> builtInShortcutEvents = [
|
|||||||
handler: selectAllHandler,
|
handler: selectAllHandler,
|
||||||
),
|
),
|
||||||
ShortcutEvent(
|
ShortcutEvent(
|
||||||
key: 'page up / page down',
|
key: 'Page up',
|
||||||
command: 'page up,page down',
|
command: 'page up',
|
||||||
handler: pageUpDownHandler,
|
handler: pageUpHandler,
|
||||||
|
),
|
||||||
|
ShortcutEvent(
|
||||||
|
key: 'Page down',
|
||||||
|
command: 'page down',
|
||||||
|
handler: pageDownHandler,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user