On Thursday, December 16, 2021 at 2:26:52 PM UTC-8, Alan Grunwald wrote:
I'm playing around with a context (right-click) menu for something I've written, but I'm having a little trouble working out when it should be unposted.
Originally I unposted it when the cursor left the menu window, which
worked fine until I added a cascade to the menu, since the context menu
is unposted as soon as the pointer leaves it and enters the cascaded
menu to select an entry there.
I could change things so that the context menu is only unposted if the pointer enters a window other than the cascade menu, but this feels as though it would get complicated really quickly. I'm confident that I
could code this up, but experience suggests that there's usually an
easier - hence better - way.
There are 2 scenarios: 1) The right-mouse button is pressed and then released. In this case, the menu is posted and remains until either, the users selects a menu item (w/ press, release), or the user clicks anywhere outside the menu. And 2) right-
mouse button press, and held. The menu should appear and remain until the right-mouse button is released. If released over an item, that item is invoked, otherwise, if released outside of the menu, the whole menu is unposted.
Tk's default behavior already addresses this when using [tk_popup].
-Brian
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)