I'm facing an issue (Unwanted Focus Shift when Clicking Menu Functions in Emacs Mode Line) regarding mouse event handling in buffer windows during menus opening. To address this, I'm attempting to temporarily inhibit mouse event handling in buffer windows when menus are opened.
Please note that by I mean 'inhibit', not 'unbind' (unset-key
). During menu opening (and for a short period after its closure, probably), windows should be completely unaware of mouse events.
This issue is crucial to me as I'm building tools for a team that uses Emacs
for editing LaTeX
documents, and I'm trying to make the system more user-friendly by organizing the many available functions into minor modes and related menus. The problem of not being able to reliably launch functions using the menus undermines my work.
The functions that give me trouble are those containing query-replace*
(the mouse event closes the function and subsequent ones) or those that use the minibuffer like read-string
(the focus switches from the minibuffer to the main window).
I have verified that, in the case of query-replace
, modifying the query-replace-map in this way:
(define-key query-replace-map [mouse-1] 'recenter)
(define-key query-replace-map [down-mouse-1] 'recenter)
etc.
partially resolves the issue.
I believe that a real solution could be to make the windows completely unaware of the mouse events during menu usage (and for a short moment after their closure).
Maybe some hooks at the opening and exiting of a menu could be helpful.
Does anyone have experience with this issue or suggestions on how to tackle it?
Note. I use easy-menu-define
to build my menus.