From 5b7c9c9234969197b452cc1b4ef8c771642164fc Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Wed, 18 Sep 2024 16:49:32 -0700 Subject: [PATCH] hitbox: extend the hitbox to the full width of the container --- src/ui/note/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ui/note/mod.rs b/src/ui/note/mod.rs index ed3f81be..75dacc63 100644 --- a/src/ui/note/mod.rs +++ b/src/ui/note/mod.rs @@ -584,8 +584,14 @@ fn note_hitbox_id(note_key: NoteKey) -> egui::Id { fn maybe_note_hitbox(ui: &mut egui::Ui, note_key: NoteKey) -> Option { ui.ctx() .data_mut(|d| d.get_persisted(note_hitbox_id(note_key))) - .map(|rect| { + .map(|mut rect: Rect| { let id = ui.make_persistent_id(("hitbox_interact", note_key)); + + // Extend the hitbox to the full width of the container + let container_rect = ui.max_rect(); + rect.min.x = container_rect.min.x; + rect.max.x = container_rect.max.x; + ui.interact(rect, id, egui::Sense::click()) }) }