Fix text selection when there's multiple viewports (#4760)

* Closes https://github.com/emilk/egui/issues/4758

Thanks to @lukexor for finding and diagnosing the problem!
This commit is contained in:
Emil Ernerfeldt 2024-07-03 10:19:03 +02:00 committed by GitHub
parent fcb7764e48
commit 1b06c69d01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -774,8 +774,11 @@ impl Context {
/// ```
pub fn begin_frame(&self, new_input: RawInput) {
crate::profile_function!();
self.read(|ctx| ctx.plugins.clone()).on_begin_frame(self);
self.write(|ctx| ctx.begin_frame_mut(new_input));
// Plugs run just after the frame has started:
self.read(|ctx| ctx.plugins.clone()).on_begin_frame(self);
}
}
@ -1807,6 +1810,7 @@ impl Context {
crate::gui_zoom::zoom_with_keyboard(self);
}
// Plugins run just before the frame ends.
self.read(|ctx| ctx.plugins.clone()).on_end_frame(self);
#[cfg(debug_assertions)]

View File

@ -154,13 +154,15 @@ impl LabelSelectionState {
}
pub fn load(ctx: &Context) -> Self {
ctx.data(|data| data.get_temp::<Self>(Id::NULL))
let id = Id::new(ctx.viewport_id());
ctx.data(|data| data.get_temp::<Self>(id))
.unwrap_or_default()
}
pub fn store(self, ctx: &Context) {
let id = Id::new(ctx.viewport_id());
ctx.data_mut(|data| {
data.insert_temp(Id::NULL, self);
data.insert_temp(id, self);
});
}