Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to KeyEvent from RawKeyEvent #1593

Merged
merged 9 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 4 additions & 3 deletions super_editor/lib/src/default_editor/blockquote.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:super_editor/src/core/editor.dart';
import 'package:super_editor/src/default_editor/attributions.dart';
import 'package:super_editor/src/infrastructure/_logging.dart';
import 'package:super_editor/src/infrastructure/attributed_text_styles.dart';
import 'package:super_editor/src/infrastructure/key_event_extensions.dart';
import 'package:super_editor/src/infrastructure/keyboard.dart';

import '../core/document.dart';
Expand Down Expand Up @@ -245,13 +246,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 +278,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 @@ -162,9 +162,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
Loading