• When to unpost a context menu?

    From Alan Grunwald@21:1/5 to All on Thu Dec 16 22:26:29 2021
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From briang@21:1/5 to Alan Grunwald on Fri Dec 17 13:11:43 2021
    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)
  • From Alan Grunwald@21:1/5 to briang on Sun Dec 19 16:36:14 2021
    On 17/12/2021 21:11, briang wrote:
    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

    Thanks Brian - sorry for the slow response; there were other things
    wrong with my script that needed to be addressed first. I had overlooked [tk_popup], having tried to roll my own, I appreciate the need for and desirability of the procedure.

    Alan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)