|
|
|
@ -577,6 +577,8 @@ class RawEditorState extends EditorState |
|
|
|
|
_onChangeTextEditingValue(!_hasFocus); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
HardwareKeyboard.instance.addHandler(_hardwareKeyboardEvent); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -585,6 +587,27 @@ class RawEditorState extends EditorState |
|
|
|
|
widget.focusNode.addListener(_handleFocusChanged); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// KeyboardVisibilityController only checks for keyboards that |
|
|
|
|
// adjust the screen size. Also watch for hardware keyboards |
|
|
|
|
// that don't alter the screen (i.e. Chromebook, Android tablet |
|
|
|
|
// and any hardware keyboards from an OS not listed in isKeyboardOS()) |
|
|
|
|
bool _hardwareKeyboardEvent(KeyEvent _) { |
|
|
|
|
if (!_keyboardVisible) { |
|
|
|
|
// hardware keyboard key pressed. Set visibility to true |
|
|
|
|
_keyboardVisible = true; |
|
|
|
|
// update the editor |
|
|
|
|
_onChangeTextEditingValue(!_hasFocus); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// remove the key handler - it's no longer needed. If |
|
|
|
|
// KeyboardVisibilityController clears visibility, it wil |
|
|
|
|
// also enable it when appropriate. |
|
|
|
|
HardwareKeyboard.instance.removeHandler(_hardwareKeyboardEvent); |
|
|
|
|
|
|
|
|
|
// we didn't handle the event, just needed to know a key was pressed |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void didChangeDependencies() { |
|
|
|
|
super.didChangeDependencies(); |
|
|
|
@ -657,6 +680,7 @@ class RawEditorState extends EditorState |
|
|
|
|
void dispose() { |
|
|
|
|
closeConnectionIfNeeded(); |
|
|
|
|
_keyboardVisibilitySubscription?.cancel(); |
|
|
|
|
HardwareKeyboard.instance.removeHandler(_hardwareKeyboardEvent); |
|
|
|
|
assert(!hasConnection); |
|
|
|
|
_selectionOverlay?.dispose(); |
|
|
|
|
_selectionOverlay = null; |
|
|
|
|