From f9187a3bc7e20d300503f0dc277a0c18622d40d7 Mon Sep 17 00:00:00 2001 From: triangle drawer <48007646+t18b219k@users.noreply.github.com> Date: Thu, 16 Nov 2023 11:31:30 +0900 Subject: [PATCH] restrict overflowing IME candidate window --- widget/src/text_input.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs index 14571fe4a7..7af07c6c5f 100644 --- a/widget/src/text_input.rs +++ b/widget/src/text_input.rs @@ -733,14 +733,14 @@ where let cursor_index = find_cursor_position(bounds, value, state, target) .unwrap_or(0); - let (offset, _) = measure_cursor_and_scroll_offset( + let (width, offset) = measure_cursor_and_scroll_offset( &state.value, bounds, cursor_index, ); ime.set_ime_position( - (bounds.x + offset) as i32, - bounds.y as i32, + (bounds.x + width - offset) as i32, + (bounds.y + bounds.height) as i32, ); } else if focus_lost { let mut editor = Editor::new(value, &mut state.cursor); @@ -1133,13 +1133,13 @@ where paragraph.update(whole_text); { - let (width, _) = measure_cursor_and_scroll_offset( + let (width, offset) = measure_cursor_and_scroll_offset( ¶graph, text_bounds, before_preedit_cursor + preedit_text.chars().count(), ); let position = ( - (text_bounds.x + width) as i32, + (text_bounds.x + width - offset) as i32, (text_bounds.y + text_bounds.height) as i32, ); ime.set_ime_position(position.0, position.1);