fix, flutter, keyboard mode

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-11-29 21:31:27 +08:00
parent 1589209567
commit 4a9e7f29da
2 changed files with 21 additions and 8 deletions

View File

@@ -159,7 +159,7 @@ class ToReleaseKeys {
class InputModel {
final WeakReference<FFI> parent;
String keyboardMode = "legacy";
String keyboardMode = '';
// keyboard
var shift = false;
@@ -194,6 +194,24 @@ class InputModel {
InputModel(this.parent) {
sessionId = parent.target!.sessionId;
// It is ok to call updateKeyboardMode() directly.
// Because `bind` is initialized in `PlatformFFI.init()` which is called very early.
// But we still wrap it in a Future.delayed() to make it more clear.
Future.delayed(Duration(milliseconds: 100), () {
updateKeyboardMode();
});
}
updateKeyboardMode() async {
// * Currently mobile does not enable map mode
if (isDesktop) {
if (keyboardMode.isEmpty) {
keyboardMode =
await bind.sessionGetKeyboardMode(sessionId: sessionId) ??
kKeyLegacyMode;
}
}
}
KeyEventResult handleRawKeyEvent(RawKeyEvent e) {
@@ -201,13 +219,6 @@ class InputModel {
return KeyEventResult.handled;
}
// * Currently mobile does not enable map mode
if (isDesktop) {
bind.sessionGetKeyboardMode(sessionId: sessionId).then((result) {
keyboardMode = result.toString();
});
}
final key = e.logicalKey;
if (e is RawKeyDownEvent) {
if (!e.repeat) {