Skip to content

Commit

Permalink
Consider layer transform when positioning text agent (emilk#4319)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
juancampa authored Apr 5, 2024
1 parent 2342788 commit 78d95f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,15 @@ impl<'t> TextEdit<'t> {
);
}

// For IME, so only set it when text is editable and visible!
// Set IME output (in screen coords) when text is editable and visible
let transform = ui
.memory(|m| m.layer_transforms.get(&ui.layer_id()).cloned())
.unwrap_or_default();

ui.ctx().output_mut(|o| {
o.ime = Some(crate::output::IMEOutput {
rect,
cursor_rect: primary_cursor_rect,
rect: transform * rect,
cursor_rect: transform * primary_cursor_rect,
});
});
}
Expand Down

0 comments on commit 78d95f4

Please sign in to comment.