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) {
|
void handleInput(String newValue) {
|
||||||
if (_value[0] == '\1' && newValue[0] != '\1') {
|
var oldValue = _value;
|
||||||
// clipboard
|
_value = newValue;
|
||||||
_value = '';
|
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';
|
final char = 'VK_BACK';
|
||||||
FFI.inputKey(char);
|
FFI.inputKey(char);
|
||||||
} else {
|
} else {
|
||||||
final content = newValue.substring(_value.length);
|
final content = newValue.substring(oldValue.length);
|
||||||
if (content.length > 1) {
|
if (content.length > 1) {
|
||||||
if (_value != '' &&
|
if (oldValue != '' &&
|
||||||
content.length == 2 &&
|
content.length == 2 &&
|
||||||
(content == '""' ||
|
(content == '""' ||
|
||||||
content == '()' ||
|
content == '()' ||
|
||||||
@ -143,15 +175,19 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
}
|
}
|
||||||
FFI.setByName('input_string', content);
|
FFI.setByName('input_string', content);
|
||||||
} else {
|
} else {
|
||||||
var char = content;
|
inputChar(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void inputChar(String char) {
|
||||||
if (char == '\n') {
|
if (char == '\n') {
|
||||||
char = 'VK_RETURN';
|
char = 'VK_RETURN';
|
||||||
|
} else if (char == ' ') {
|
||||||
|
char = 'VK_SPACE';
|
||||||
}
|
}
|
||||||
FFI.inputKey(char);
|
FFI.inputKey(char);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_value = newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void openKeyboard() {
|
void openKeyboard() {
|
||||||
// destroy first, so that our _value trick can work
|
// destroy first, so that our _value trick can work
|
||||||
|
Loading…
x
Reference in New Issue
Block a user