Skip to content

Commit ea3e39a

Browse files
committed
Open ContextMenu on pointer button press, not click
clicks only occur on button release, button press feels more responsive
1 parent cbfc743 commit ea3e39a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

egui/src/context_menu.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl ContextMenuSystem {
1717
fn sense_click(&mut self, response: &Response) -> MenuResponse {
1818
let response = response.interact(Sense::click());
1919
let pointer = &response.ctx.input().pointer;
20-
if pointer.any_click() {
20+
if pointer.any_pressed() {
2121
if let Some(pos) = pointer.interact_pos() {
2222
let mut destroy = false;
2323
let mut in_old_menu = false;
@@ -26,9 +26,10 @@ impl ContextMenuSystem {
2626
destroy = context_menu.ui_id == response.id;
2727
}
2828
if !in_old_menu {
29-
if response.secondary_clicked() {
29+
let in_target = response.rect.contains(pos);
30+
if in_target && pointer.secondary_down() {
3031
return MenuResponse::Create(pos);
31-
} else if response.clicked() || destroy {
32+
} else if (in_target && pointer.primary_down()) || destroy {
3233
return MenuResponse::Close;
3334
}
3435
}

0 commit comments

Comments
 (0)