ime works fine now on iOS
This commit is contained in:
parent
4d730586ae
commit
72adcacce9
@ -115,17 +115,49 @@ class _RemotePageState extends State<RemotePage> {
|
||||
}
|
||||
|
||||
void handleInput(String newValue) {
|
||||
if (_value[0] == '\1' && newValue[0] != '\1') {
|
||||
// clipboard
|
||||
_value = '';
|
||||
var oldValue = _value;
|
||||
_value = newValue;
|
||||
if (Platform.isIOS) {
|
||||
var i = newValue.length - 1;
|
||||
for (; i >= 0 && newValue[i] != '\1'; --i) {}
|
||||
var j = oldValue.length - 1;
|
||||
for (; j >= 0 && oldValue[j] != '\1'; --j) {}
|
||||
if (i < j) j = i;
|
||||
newValue = newValue.substring(j + 1);
|
||||
oldValue = oldValue.substring(j + 1);
|
||||
var common = 0;
|
||||
for (;
|
||||
common < oldValue.length &&
|
||||
common < newValue.length &&
|
||||
newValue[common] == oldValue[common];
|
||||
++common);
|
||||
for (i = 0; i < oldValue.length - common; ++i) {
|
||||
FFI.inputKey('VK_BACK');
|
||||
}
|
||||
if (newValue.length <= _value.length) {
|
||||
if (newValue.length > common) {
|
||||
var s = newValue.substring(common);
|
||||
if (s.length > 1) {
|
||||
FFI.setByName('input_string', s);
|
||||
} else {
|
||||
inputChar(s);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (oldValue.length > 0 &&
|
||||
newValue.length > 0 &&
|
||||
oldValue[0] == '\1' &&
|
||||
newValue[0] != '\1') {
|
||||
// clipboard
|
||||
oldValue = '';
|
||||
}
|
||||
if (newValue.length <= oldValue.length) {
|
||||
final char = 'VK_BACK';
|
||||
FFI.inputKey(char);
|
||||
} else {
|
||||
final content = newValue.substring(_value.length);
|
||||
final content = newValue.substring(oldValue.length);
|
||||
if (content.length > 1) {
|
||||
if (_value != '' &&
|
||||
if (oldValue != '' &&
|
||||
content.length == 2 &&
|
||||
(content == '""' ||
|
||||
content == '()' ||
|
||||
@ -143,15 +175,19 @@ class _RemotePageState extends State<RemotePage> {
|
||||
}
|
||||
FFI.setByName('input_string', content);
|
||||
} else {
|
||||
var char = content;
|
||||
inputChar(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void inputChar(String char) {
|
||||
if (char == '\n') {
|
||||
char = 'VK_RETURN';
|
||||
} else if (char == ' ') {
|
||||
char = 'VK_SPACE';
|
||||
}
|
||||
FFI.inputKey(char);
|
||||
}
|
||||
}
|
||||
_value = newValue;
|
||||
}
|
||||
|
||||
void openKeyboard() {
|
||||
// destroy first, so that our _value trick can work
|
||||
|
Loading…
x
Reference in New Issue
Block a user