summaryrefslogtreecommitdiffstats
path: root/generic/tkMenu.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2019-02-02 17:52:16 (GMT)
committerfvogel <fvogelnew1@free.fr>2019-02-02 17:52:16 (GMT)
commit14737a26b79ca3ec601d37c736c0651c60eed937 (patch)
tree89ac52a4f2d164e7407f96742f178447fbbf20ff /generic/tkMenu.c
parent591f68cb382525b72664c6fecaab87742b6cc87a (diff)
parent6f9b782763a6e1605f10e734efa396ec738a04e0 (diff)
downloadtk-14737a26b79ca3ec601d37c736c0651c60eed937.zip
tk-14737a26b79ca3ec601d37c736c0651c60eed937.tar.gz
tk-14737a26b79ca3ec601d37c736c0651c60eed937.tar.bz2
TIP #533 (Extension of the menu post command) implementation was accepted by TCT vote. This allows fixing of bug [70e531918e]: geometry issues with menubuttons on macOS.
Diffstat (limited to 'generic/tkMenu.c')
-rw-r--r--generic/tkMenu.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index d5c63f7..dd29d79 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -873,32 +873,37 @@ MenuWidgetObjCmd(
break;
}
case MENU_POST: {
- int x, y;
+ int x, y, index = -1;
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "x y");
+ if (objc != 4 && objc != 5) {
+ Tcl_WrongNumArgs(interp, 2, objv, "x y ?index?");
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 (TkGetMenuIndex(interp, menuPtr, objv[4], 0, &index) != 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, index);
} else {
- result = TkPostTearoffMenu(interp, menuPtr, x, y);
+ result = TkpPostTearoffMenu(interp, menuPtr, x, y, index);
}
break;
}