Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix text selection when there's multiple viewports #4760

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)]
Expand Down
6 changes: 4 additions & 2 deletions crates/egui/src/text_selection/label_text_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down
Loading