From ab19054c699a4edb7222aafe4595c79a139d4fe4 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 14 Aug 2014 02:41:52 +0000 Subject: Allow Tk to post popup menus when Tk app is not frontmost --- macosx/tkMacOSXMenu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 313a5cf..a8e9f2f 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -757,10 +757,18 @@ TkpPostMenu( * to be posted. */ int y) /* The global y-coordinate */ { - NSWindow *win = [NSApp keyWindow]; - if (!win) { + + + /* Get the object that holds this Tk Window.*/ + Tk_Window root; + root = Tk_MainWindow(interp); + if (root == NULL) { return TCL_ERROR; } + + Drawable d = Tk_WindowId(root); + NSView *rootview = TkMacOSXGetRootControl(d); + NSWindow *win = [rootview window]; inPostMenu = 1; -- cgit v0.12