emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Context Menu


From: Ergus
Subject: Re: New Context Menu
Date: Thu, 19 Aug 2021 15:57:01 +0200

On Thu, Aug 19, 2021 at 10:01:10AM +0300, Juri Linkov wrote:
The current implementation follows the X11 menu interaction pattern:
Hold mouse-3 to keep the menu active and release mouse-3 to select an
entry.

Could we add an option to avoid this and have the same interaction
behavior than in gui please?: mouse-3 activates the menu, a click over
an option selects it and a click outside the menu hides the menu

When you press down-mouse-1 and immediately release the mouse button,
it has the same effect as if you clicked mouse-1: it displays the menu
without selecting a menu item.  So with the current win-win situation
both scenarios are supported:

1. one click: down-mouse-1, select a menu item, release mouse-1;
2. two clicks: click mouse-1, select a menu item by clicking mouse-1 again.


Both ways work on xterm as well - you can easily select a menu item with
one click on xterm too.


Hi Juri:

For me only 1. works now as you describe on xterm.

Whenever I try 2. it doesn't work the menu disappears when I release the
button either fast or slow. With the problem that releasing fast usually
selects the first item (generally Undo).

On gui it works as you describe.

Maybe this is something deeper related with the menu API, I don't
know...

In case the user wants to bind the context menu without using the mouse
how can be done? Will the context-menu appear in the current cursor
(point) or in the current mouse arrow position?

This is possible, but the menu appears at the left top corner,
as for example it appears on typing 'C-<f10>' that runs the command
buffer-menu-open.  Here is its implementation:

 (defun buffer-menu-open ()
   "Start key navigation of the buffer menu.
 This is the keyboard interface to \\[mouse-buffer-menu]."
   (interactive)
   (popup-menu (mouse-buffer-menu-keymap)
               (posn-at-x-y 0 0 nil t)))

We could do the same with:

   (popup-menu (context-menu-map)
               (posn-at-x-y 0 0 nil t))

Or do it much better:

   (popup-menu (context-menu-map)
               (point))

What would a good key to bind such command?  Maybe 'S-<f10>'?

There is the menu key that nobody seems to use because since 2007 nobody
noticed that it is not bound for xterm. Everywhere else (browsers,
editors, explorers) the menu key has the same effect than right click,
so if we want a binding, this is the right one. Sadly
execute-extended-command is bound to [menu]; but the user may know that
when context-menu is enabled, that binding is replaced for something
standard... (or add a custom to set it).

I just started another thread about [menu] not bound in xterm.

But please note that currently when you select a menu item
using the keyboard, many commands will fail with

 (error "Command must be bound to an event with parameters")

The dirty but functional solution for this may be to create a
function/macro that emulates a full event. Because I don't know how
difficult may be to modify the events api to distinguish when the mouse
was used or use the point otherwise...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]