Skip to content

Commit

Permalink
Fix: Response.interact_pointer_pos is Some on click and drag rele…
Browse files Browse the repository at this point in the history
…ased (#4014)

* Closes #3999

In 0.26.0 is was accidentally set to `None` on the frame we got a click
or drag release
  • Loading branch information
emilk authored Feb 10, 2024
1 parent 5bf44f8 commit 0bf3056
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,11 @@ impl Context {
}
}

if res.is_pointer_button_down_on {
// is_pointer_button_down_on is false when released, but we want interact_pointer_pos
// to still work.
let clicked = res.clicked.iter().any(|c| *c);
let is_interacted_with = res.is_pointer_button_down_on || clicked || res.drag_released;
if is_interacted_with {
res.interact_pointer_pos = input.pointer.interact_pos();
}

Expand Down
3 changes: 3 additions & 0 deletions crates/egui_demo_lib/src/demo/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ fn response_summary(response: &egui::Response, show_hovers: bool) -> String {
if response.is_pointer_button_down_on() {
writeln!(new_info, "pointer_down_on").ok();
}
if let Some(pos) = response.interact_pointer_pos() {
writeln!(new_info, "response.interact_pointer_pos: {pos:?}").ok();
}
}

for &button in &[
Expand Down

0 comments on commit 0bf3056

Please sign in to comment.