diff options
author | culler <culler> | 2019-01-11 21:47:27 (GMT) |
---|---|---|
committer | culler <culler> | 2019-01-11 21:47:27 (GMT) |
commit | da7c298f108280140fbbec81f67705f684bf5fe6 (patch) | |
tree | 74cb6130471b57b3663cec8d929c8786c922388f /generic | |
parent | d155557faa7d1e039c912fc21ffccaf160c26b8e (diff) | |
download | tk-da7c298f108280140fbbec81f67705f684bf5fe6.zip tk-da7c298f108280140fbbec81f67705f684bf5fe6.tar.gz tk-da7c298f108280140fbbec81f67705f684bf5fe6.tar.bz2 |
Fix related menubutton issues on linux and Windows.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkMenu.c | 32 | ||||
-rw-r--r-- | generic/tkMenu.h | 2 |
2 files changed, 24 insertions, 10 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 26ffc88..f1ea8ff 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -870,32 +870,46 @@ MenuWidgetObjCmd( break; } case MENU_POST: { - int x, y; + int x, y, entry = -1; - if (objc != 4) { - Tcl_WrongNumArgs(interp, 2, objv, "x y"); + if (objc != 4 && objc != 5) { + Tcl_WrongNumArgs(interp, 2, objv, "x y ?entry?"); goto error; } if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { goto error; } + if (objc == 5) { + if (menuPtr->menuType == TEAROFF_MENU) { + Tcl_AppendResult(interp, + "the index option is invalid for tearoff menus", NULL); + return TCL_ERROR; + } + if (Tcl_GetIntFromObj(interp, objv[4], &entry) != TCL_OK) { + goto error; + } + } /* - * Tearoff menus are posted differently on Mac and Windows than - * non-tearoffs. TkpPostMenu does not actually map the menu's window - * on those platforms, and popup menus have to be handled specially. - * Also, menubar menues are not intended to be posted (bug 1567681, - * 2160206). + * Tearoff menus are the same as ordinary menus on the Mac and are + * posted differently on Windows than non-tearoffs. TkpPostMenu + * does not actually map the menu's window on those platforms, and + * popup menus have to be handled specially. Also, menubar menus are + * not intended to be posted (bug 1567681, 2160206). */ if (menuPtr->menuType == MENUBAR) { Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL); return TCL_ERROR; } else if (menuPtr->menuType != TEAROFF_MENU) { - result = TkpPostMenu(interp, menuPtr, x, y); + result = TkpPostMenu(interp, menuPtr, x, y, entry); } else { +#ifdef TK_MAC_OSX + result = TkpPostMenu(interp, menuPtr, x, y, entry); +#else result = TkPostTearoffMenu(interp, menuPtr, x, y); +#endif } break; } diff --git a/generic/tkMenu.h b/generic/tkMenu.h index bac51aa..92bf8b2 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -543,7 +543,7 @@ MODULE_SCOPE void TkpMenuInit(void); MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr); MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr); MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y); + int x, int y, int entry); MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr); #endif /* _TKMENU */ |