Skip to content

Commit

Permalink
Migrate to KeyEvent from RawKeyEvent (Flutter team contribution) (sup…
Browse files Browse the repository at this point in the history
  • Loading branch information
gspencergoog authored and dxvid-pts committed Feb 11, 2024
1 parent 6ab48a9 commit 086f338
Show file tree
Hide file tree
Showing 26 changed files with 2,130 additions and 719 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:super_text_layout/super_text_layout.dart';

/// Demo that displays a very limited iOS text field, constructed from
/// the ground up, using [TextInput] for user interaction instead
/// of a [RawKeyboardListener] or similar.
/// of a [KeyboardListener] or similar.
class BarebonesIosTextInputClientDemo extends StatefulWidget {
@override
State<BarebonesIosTextInputClientDemo> createState() => _BarebonesIosTextInputClientDemoState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:super_text_layout/super_text_layout.dart';

/// Demo that displays a very limited text field, constructed from
/// the ground up, and using [TextInput] for user interaction instead
/// of a [RawKeyboardListener] or similar.
/// of a [KeyboardListener] or similar.
class BasicTextInputClientDemo extends StatefulWidget {
@override
State<BasicTextInputClientDemo> createState() => _BasicTextInputClientDemoState();
Expand Down
6 changes: 3 additions & 3 deletions super_editor/lib/src/default_editor/blockquote.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,13 @@ class ConvertBlockquoteToParagraphCommand implements EditCommand {

ExecutionInstruction insertNewlineInBlockquote({
required SuperEditorContext editContext,
required RawKeyEvent keyEvent,
required KeyEvent keyEvent,
}) {
if (keyEvent.logicalKey != LogicalKeyboardKey.enter) {
return ExecutionInstruction.continueExecution;
}

if (!keyEvent.isShiftPressed) {
if (!HardwareKeyboard.instance.isShiftPressed) {
return ExecutionInstruction.continueExecution;
}

Expand All @@ -277,7 +277,7 @@ ExecutionInstruction insertNewlineInBlockquote({

ExecutionInstruction splitBlockquoteWhenEnterPressed({
required SuperEditorContext editContext,
required RawKeyEvent keyEvent,
required KeyEvent keyEvent,
}) {
if (keyEvent.logicalKey != LogicalKeyboardKey.enter) {
return ExecutionInstruction.continueExecution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ class _DocumentMouseInteractorState extends State<DocumentMouseInteractor> with
}

bool get _isShiftPressed =>
(RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.shiftLeft) ||
RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.shiftRight) ||
RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.shift)) &&
(HardwareKeyboard.instance.logicalKeysPressed.contains(LogicalKeyboardKey.shiftLeft) ||
HardwareKeyboard.instance.logicalKeysPressed.contains(LogicalKeyboardKey.shiftRight) ||
HardwareKeyboard.instance.logicalKeysPressed.contains(LogicalKeyboardKey.shift)) &&
// TODO: this condition doesn't belong here. Move it to where it applies
_currentSelection != null;

Expand Down
Loading

0 comments on commit 086f338

Please sign in to comment.