fix, flutter, keyboard mode
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
1589209567
commit
4a9e7f29da
@ -1628,6 +1628,7 @@ class _KeyboardMenu extends StatelessWidget {
|
|||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
await bind.sessionSetKeyboardMode(
|
await bind.sessionSetKeyboardMode(
|
||||||
sessionId: ffi.sessionId, value: value);
|
sessionId: ffi.sessionId, value: value);
|
||||||
|
await ffi.inputModel.updateKeyboardMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (InputModeMenu mode in modes) {
|
for (InputModeMenu mode in modes) {
|
||||||
@ -1704,6 +1705,7 @@ class _KeyboardMenu extends StatelessWidget {
|
|||||||
if (v != null) {
|
if (v != null) {
|
||||||
await stateGlobal.setInputSource(ffi.sessionId, v);
|
await stateGlobal.setInputSource(ffi.sessionId, v);
|
||||||
await ffi.ffiModel.checkDesktopKeyboardMode();
|
await ffi.ffiModel.checkDesktopKeyboardMode();
|
||||||
|
await ffi.inputModel.updateKeyboardMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
@ -159,7 +159,7 @@ class ToReleaseKeys {
|
|||||||
|
|
||||||
class InputModel {
|
class InputModel {
|
||||||
final WeakReference<FFI> parent;
|
final WeakReference<FFI> parent;
|
||||||
String keyboardMode = "legacy";
|
String keyboardMode = '';
|
||||||
|
|
||||||
// keyboard
|
// keyboard
|
||||||
var shift = false;
|
var shift = false;
|
||||||
@ -194,6 +194,24 @@ class InputModel {
|
|||||||
|
|
||||||
InputModel(this.parent) {
|
InputModel(this.parent) {
|
||||||
sessionId = parent.target!.sessionId;
|
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) {
|
KeyEventResult handleRawKeyEvent(RawKeyEvent e) {
|
||||||
@ -201,13 +219,6 @@ class InputModel {
|
|||||||
return KeyEventResult.handled;
|
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;
|
final key = e.logicalKey;
|
||||||
if (e is RawKeyDownEvent) {
|
if (e is RawKeyDownEvent) {
|
||||||
if (!e.repeat) {
|
if (!e.repeat) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user