Skip to content

Commit 0fd0de0

Browse files
juancampahacknus
authored andcommitted
Consider layer transform when positioning text agent (emilk#4319)
When positioning the text agent, the layer transform was not being considered. This not only caused issues with IME input positioning but also layout shifts if the text agent was off-screen. Before ![Screenshot 2024-04-04 at 13 33 11@2x](https://github.com/emilk/egui/assets/1410520/5d88a358-67bd-478c-95c9-d76f84d57c39) After ![Screenshot 2024-04-04 at 13 31 52@2x](https://github.com/emilk/egui/assets/1410520/55f068c7-56fe-4ba4-8455-7d0f613e8a52)
1 parent 05665a3 commit 0fd0de0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/egui/src/widgets/text_edit/builder.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,15 @@ impl<'t> TextEdit<'t> {
700700
);
701701
}
702702

703-
// For IME, so only set it when text is editable and visible!
703+
// Set IME output (in screen coords) when text is editable and visible
704+
let transform = ui
705+
.memory(|m| m.layer_transforms.get(&ui.layer_id()).cloned())
706+
.unwrap_or_default();
707+
704708
ui.ctx().output_mut(|o| {
705709
o.ime = Some(crate::output::IMEOutput {
706-
rect,
707-
cursor_rect: primary_cursor_rect,
710+
rect: transform * rect,
711+
cursor_rect: transform * primary_cursor_rect,
708712
});
709713
});
710714
}

0 commit comments

Comments
 (0)