Tk Source Code

View Ticket
Login
Ticket UUID: 3603738
Title: menus can't post if application is not in foreground
Type: Bug Version: current: 8.6.0
Submitter: Created on: 2013-02-07 19:30:15
Subsystem: 11. Aqua Menus Assigned To: wordtech
Priority: 5 Medium Severity:
Status: Open Last Modified: 2013-03-25 20:52:51
Resolution: None Closed By: wordtech
    Closed on: 2013-03-24 18:21:56
Description:
A popup menu causes an error if you try to post it while another application is in the foreground.

test code:
menu .pm 
.pm add command -label test
bind . <Button-2> "tk_popup .pm %X %Y"

works fine if Wish is in the foreground.
If you click on any other application, then right-click on the Wish window (while leaving it in the background) an error is thrown on the .pm post command.
User Comments: wordtech added on 2013-03-25 20:52:51:

allow_comments - 0

That's a sensible suggestion--I'll take a look at implementing this.

dkf added on 2013-03-25 19:29:41:
But arguably we ought to be more graceful about this failure case. Even if it can't work, it shouldn't throw an error in the user's face. Suggest trapping (just) this particular error in [tk_popup]…

wordtech added on 2013-03-25 01:21:56:

allow_comments - 1

wordtech added on 2013-03-25 01:21:03:
Looking at the implementation in tkMacOSXMenu.c, it appears that the popup menu requires a window reference that can only be obtained via [NSApp keyWindow]--c.f. a window with focus. I don't see another way to do it in Tk.