|
|
|
@ -63,12 +63,44 @@ mixin RawEditorStateTextInputClientMixin on EditorState |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
_updateSizeAndTransform(); |
|
|
|
|
//update IME position for Windows |
|
|
|
|
_updateComposingRectIfNeeded(); |
|
|
|
|
//update IME position for Macos |
|
|
|
|
_updateCaretRectIfNeeded(); |
|
|
|
|
_textInputConnection!.setEditingState(_lastKnownRemoteTextEditingValue!); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_textInputConnection!.show(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _updateComposingRectIfNeeded() { |
|
|
|
|
final composingRange = _lastKnownRemoteTextEditingValue?.composing ?? |
|
|
|
|
textEditingValue.composing; |
|
|
|
|
if (hasConnection) { |
|
|
|
|
assert(mounted); |
|
|
|
|
final offset = composingRange.isValid ? composingRange.start : 0; |
|
|
|
|
final composingRect = |
|
|
|
|
renderEditor.getLocalRectForCaret(TextPosition(offset: offset)); |
|
|
|
|
_textInputConnection!.setComposingRect(composingRect); |
|
|
|
|
SchedulerBinding.instance |
|
|
|
|
.addPostFrameCallback((_) => _updateComposingRectIfNeeded()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _updateCaretRectIfNeeded() { |
|
|
|
|
if (hasConnection) { |
|
|
|
|
if (renderEditor.selection.isValid && |
|
|
|
|
renderEditor.selection.isCollapsed) { |
|
|
|
|
final currentTextPosition = |
|
|
|
|
TextPosition(offset: renderEditor.selection.baseOffset); |
|
|
|
|
final caretRect = |
|
|
|
|
renderEditor.getLocalRectForCaret(currentTextPosition); |
|
|
|
|
_textInputConnection!.setCaretRect(caretRect); |
|
|
|
|
} |
|
|
|
|
SchedulerBinding.instance |
|
|
|
|
.addPostFrameCallback((_) => _updateCaretRectIfNeeded()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Closes input connection if it's currently open. Otherwise does nothing. |
|
|
|
|
void closeConnectionIfNeeded() { |
|
|
|
|
if (!hasConnection) { |
|
|
|
|