help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to bind pop up menu to a key?


From: rgb
Subject: Re: How to bind pop up menu to a key?
Date: 21 Feb 2005 22:16:30 -0800
User-agent: G2/0.2

> I want to bind the mouse-popup-menubar to a keyboard enent,
> *not* to C-mouse-3 which is the default binding. When I try
>
> (global-set-key (kbd "M-<f1>") 'mouse-popup-menubar)
>
> for example, and then I press M-<F1> I get the message
>
>       mouse-popup-menubar must be bound to an event with parameters
>
mouse-popup-menubar is defined with (interactive "@e \nP").
The `e' is an event from which it can determine the window, buffer,
and screen position to associate the popup-menu with.  In fact
it's possible that different menus will display depending on what
buffer you click in.

It seems your best chance of clean operation is to write a function
that makes up a contrived event list appropriate to your cursor
position and uses it to call mouse-popup-menubar.  It likely depends
on your windowing software if keyboard completion of the popup is
possible.  On W32 systems it is.

Between this function and the Emacs Lisp Reference manual you can
probably find a way to create the appropriate event.

(defun event-test (event)
  (interactive "@e")
  (message "Event = %s" event)
)
(global-set-key [S-mouse-3] 'event-test)

>From what returned above I was able to get the menu to pop up.
See below.  Looks promising.  The word `keyboard' was made up.
The above said S-mouse-3 like you'd expect.

M-: (mouse-popup-menubar `(keyboard (,(selected-window)
                                248 (126 . 104) 70080603
                                nil 248 (15 . 6) nil
                                (6 . 8) (8 . 16))) ()) <ret>

P.S.  The final () in the above call is the `P' prefix arg.
Your keyboard function should grab this and pass it along to
be complete.

Good luck.
If you invent something useful please post.


reply via email to

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