From d0a67ec8ad6eebde787857604c064981cb8e7666 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 8 Jan 2024 21:20:46 +0000 Subject: Restore "$menu index" to return "none" for no index (for compatibility with Tk 8.6) --- generic/tkMenu.c | 9 ++++++--- tests/menu.test | 4 ++-- tests/menuDraw.test | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/generic/tkMenu.c b/generic/tkMenu.c index d3551f9..eacdffb 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -856,12 +856,15 @@ MenuWidgetObjCmd( if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } -#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) if (index < 0) { +#if defined(TK_NO_DEPRECATED) Tcl_SetObjResult(interp, Tcl_NewObj()); - } else +#else + Tcl_SetObjResult(interp, Tcl_NewStringObj("none", TCL_INDEX_NONE)); #endif - Tcl_SetObjResult(interp, TkNewIndexObj(index)); + } else { + Tcl_SetObjResult(interp, TkNewIndexObj(index)); + } break; } case MENU_INSERT: diff --git a/tests/menu.test b/tests/menu.test index 054ac68..4e98e95 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -1864,10 +1864,10 @@ test menu-3.71 {MenuWidgetCmd procedure, "index end" option, bug [f3cd942e9e]} - destroy .m1 } -body { menu .m1 - .m1 index "end" + expr {[.m1 index "end"] in [list {} none]} } -cleanup { destroy .m1 -} -result {} +} -result 1 test menu-4.1 {TkInvokeMenu: disabled} -setup { diff --git a/tests/menuDraw.test b/tests/menuDraw.test index 2cafc31..02111ab 100644 --- a/tests/menuDraw.test +++ b/tests/menuDraw.test @@ -558,7 +558,7 @@ test menuDraw-15.2 {TkPostTearoffMenu - Deactivation} -setup { menu .m1 .m1 add command -label "foo" -state active set tearoff [tk::TearOffMenu .m1 40 40] - expr {[$tearoff index active]<0} + expr {[$tearoff index active] in [list {} none]} } -cleanup { deleteWindows } -result 1 -- cgit v0.12