Subject: Re: Popup menu implementation & mouse events

From: Richard Stallman <[email-masked]>
Date: Fri, 25 Apr 1997 18:28:01 -0400

I don't know whether this behavior fits in with Windows NT.  In
general, I would say that Emacs should handle menus like a good
Windows NT application, to the extent that it can.

    1) A menu is set up to execute on a specific mouse-down event.  A
    click for that button/modifier combination is generated.  As the menu
    was created by the mouse-down, should the click event go through?

On X Windows, if the user pushes the button and releases it quickly,
before the menu appears, then the menu should come up and stay up.
When the user pushes the button again, that should select from the
menu.

    2) A menu is set up as in 1.  If a user clicks and holds, should the
    menu pop up and allow them to select an entry by releasing the mouse
    button on a menu entry,

On X Windows, it does.

			    or should the menu wait for a seperate
    mouse-down?  Does it make a difference if this can only be implemented
    on the right and left buttons (not the middle)?

    3) If the answer for 2 is the first option, what events should be seen
    by emacs?

    4) Keeping in mind that way I am implementing popup menus is
    aplication modal, should emacs recieve any mouse-move events generated
    during menu selection?

No.

---

From: "Michael Welsh Duggan" <[email-masked]>
Date: 03 May 1997 08:36:43 -0400

> When the user pushes the button again, that should select from the

Okay, one last question:

In X Windows, in the case you have described in the preceding
paragraph, should both the mouse down and the mouse up event be
returned by kbd_buffer_get_event?  If so, where does the mouse-up
event get caught?

Actually, rereading the previous paragraph makes me realize that an
explanation of what I am trying to do is in order.  

Example and explanation:

mouse.el, which is dumped into the standard Emacs distribution,
maps the keybinding C-down-mouse-1 to the function
mouse-buffer-menu.  Clicking the first mouse button while holding
down the shift key causes two events to be inserted into the
keyboard buffer, a button down event and a button up event.  The
button down event translates into the Emacs event C-down-mouse-1,
which executes the function mouse-buffer-menu.

Ah, but here comes the questionable part.  There is still a
mouse down event in the buffer, and when mouse-buffer-menu has
completed, it translates into the Emacs event C-mouse-1.  This has
no binding and therefore ends up calling bitch_at_user, causeing a
beep.

Now, I never remember this happening when I used the X Windows
version of Emacs, so this event must be getting eaten somewhere.  My
question is this: Where should it be eaten?  Should the button up
event never have made it into the keyboard buffer, or should it be
trapped and eaten later in the function chain?

I would also like to leave you with one last question:  Was I correct
in sending this question to you (and the above CC'd), or was there a
more appropriate forum in which to ask this question?

Thanks for your time.

-- 
Michael Duggan
([email-masked])

---

From: Richard Stallman <[email-masked]>
Date: Sat, 3 May 1997 15:04:39 -0400

In X Windows, in the case you have described in the preceding
    paragraph, should both the mouse down and the mouse up event be
    returned by kbd_buffer_get_event?

With X, the menus are handled by different code entirely, part of
lwlib or some other widget set.  So the button events in the menu
are never returned by kbd_buffer_get_event at all,