mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-02-17 14:07:28 +08:00
fix: remote id, update text and reserve selection (#10867)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -3705,3 +3705,18 @@ Widget workaroundWindowBorder(BuildContext context, Widget child) {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void updateTextAndPreserveSelection(TextEditingController controller, String text) {
|
||||
final preSelectionStart = controller.selection.start;
|
||||
final preSelectionEnd = controller.selection.end;
|
||||
// Only care about select all for now.
|
||||
final isSelected = preSelectionEnd > preSelectionStart;
|
||||
|
||||
// Set text will make the selection invalid.
|
||||
controller.text = text;
|
||||
|
||||
if (isSelected) {
|
||||
controller.selection = TextSelection(
|
||||
baseOffset: 0, extentOffset: controller.value.text.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,6 +225,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
||||
}
|
||||
});
|
||||
}
|
||||
Get.put<TextEditingController>(_idEditingController);
|
||||
Get.put<IDTextEditingController>(_idController);
|
||||
windowManager.addListener(this);
|
||||
}
|
||||
@@ -395,8 +396,8 @@ class _ConnectionPageState extends State<ConnectionPage>
|
||||
FocusNode fieldFocusNode,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
fieldTextEditingController.text = _idController.text;
|
||||
Get.put<TextEditingController>(fieldTextEditingController);
|
||||
updateTextAndPreserveSelection(
|
||||
fieldTextEditingController, _idController.text);
|
||||
return Obx(() => TextField(
|
||||
autocorrect: false,
|
||||
enableSuggestions: false,
|
||||
|
||||
@@ -74,6 +74,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
}
|
||||
});
|
||||
}
|
||||
Get.put<TextEditingController>(_idEditingController);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -214,9 +215,8 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
||||
TextEditingController fieldTextEditingController,
|
||||
FocusNode fieldFocusNode,
|
||||
VoidCallback onFieldSubmitted) {
|
||||
fieldTextEditingController.text = _idController.text;
|
||||
Get.put<TextEditingController>(
|
||||
fieldTextEditingController);
|
||||
updateTextAndPreserveSelection(
|
||||
fieldTextEditingController, _idController.text);
|
||||
return AutoSizeTextField(
|
||||
controller: fieldTextEditingController,
|
||||
focusNode: fieldFocusNode,
|
||||
|
||||
Reference in New Issue
Block a user