git.lucas.co / cce-authenticator
login authentication (PAM + fingerprint)
git clone https://git.lucas.co/cce-authenticator.git

commit80ca6c7ea6f34bfca66ac5e6ff0516292795c46c
parent22affe1931
authorLucas Galante <lsgalante12@gmail.com>
date2026-10-07 10:08
Route clicks and hover to the shared context menu while it is open

A right-click on the password box opens cce-ui's shared context menu,
and cce-ui leaves routing to it to the app: no click outside it closed
it, and its rows (Cut / Copy / Paste / Select All) did nothing. While it
is open a press now goes to the menu first -- a row runs, anywhere else
dismisses -- and the pointer drives its row highlight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

 src/main.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/main.rs b/src/main.rs
index 8448575..9e38f9c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -875,6 +875,14 @@ impl Application for AuthenticatorApp {
     }
 
     fn handle_pointer_move(&mut self, pos: LogicalPosition, needs_rebuild: &mut bool) {
+        // The shared context menu (the password box's) gets the pointer to itself
+        // while open: its row highlight.
+        if cce_ui::widget::context_menu::is_visible() {
+            if cce_ui::widget::context_menu::cursor_moved(pos.x, pos.y) {
+                *needs_rebuild = true;
+            }
+            return;
+        }
         // Routed dispatch (6bd shrink): one Event per widget root through the router.
         let mv = cce_ui::widget::Event::PointerMove { x: pos.x, y: pos.y, local_x: pos.x, local_y: pos.y };
         let ctx = &mut self.ui_context;
@@ -890,6 +898,18 @@ impl Application for AuthenticatorApp {
 
     fn handle_mouse_input(&mut self, button: MouseButton, state: ElementState, pos: LogicalPosition, needs_rebuild: &mut bool) -> Option<Self::Message> {
         let (lx, ly) = (pos.x, pos.y);
+
+        // The shared context menu a right-click on the password box opens takes
+        // every click while open: a row runs, a press anywhere else dismisses it.
+        // The toolkit leaves this routing to the app; without it the menu could
+        // not be closed by clicking outside it, and its rows did nothing.
+        if cce_ui::widget::context_menu::is_visible() {
+            if cce_ui::widget::context_menu::mouse_input(button, state, lx, ly, Some(&mut self.ui_context)) {
+                *needs_rebuild = true;
+            }
+            return None;
+        }
+
         let ev = cce_ui::widget::Event::MouseButton { button, state, x: lx, y: ly, local_x: lx, local_y: ly };
 
         if { let root = self.verify_btn.id(); self.ui_context.propagate_event(&ev, root) } {