git.lucas.co / cce-secrets
secrets manager
git clone https://git.lucas.co/cce-secrets.git

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

A right-click on the search box or an entry field 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 did nothing. While it is open a press
now goes to the menu first -- after the release that ends a scrollbar
thumb drag, which must still land -- 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 6047ef2..e19c368 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1566,6 +1566,14 @@ impl Application for SecretsApp {
                 *needs_rebuild = true;
             }
         }
+        // The shared context menu (a text 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;
+        }
         let mv = cce_ui::widget::Event::PointerMove { x: pos.x, y: pos.y, local_x: pos.x, local_y: pos.y };
         let mut roots = vec![self.search_box.id()];
         roots.extend(self.buttons_mut().map(|b| b.id()));
@@ -1599,6 +1607,18 @@ impl Application for SecretsApp {
             *needs_rebuild = true;
         }
 
+        // The shared context menu a right-click on a text box opens takes every
+        // click while open (after the release above, so a thumb drag still
+        // ends): 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;
+        }
+
         // Buttons: propagate, then drain clicks into messages.
         let button_roots: Vec<_> = {
             let bs = self.buttons_mut();