If a menu contains an item whose label is an integer,
then menu index returns the value of that menu item,
or if the integer is too large, then it returns
the index of the last item in the menu.
Here is a procedure to see this.
Enter it into wish and select menu items to see the index.
The index of entry "3" is reported as 3, but should be 1.
menubutton .mb -m .mb.menu -text testmenu
pack .mb
set m [menu .mb.menu]
$m add command -label foo -command {puts "foo: [$m index foo]"}
$m add command -label 3 -command {puts "3: [$m index 3]"}
$m add command -label 3a -command {puts "3: [$m index 3a]"}
$m add command -label bar -command {puts "bar: [$m index bar]"}
$m add command -label baz -command {puts "baz: [$m index baz]"}
I saw this on ActiveState Aqua Tcl/Tk 8.4.13 on MacOS X 10.4.7. I have
not tried to duplicate it on other operating systems nor with 8.4.14
(since the ActiveState version is not yet available).
Logged In: YES
user_id=1245417
Reproduced on WinXP with 8.4.13.
Logged In: YES
user_id=32170
This is the correct behaviour. The man page specifies that '$m index $X'
interprets 'X' as a number or as a pattern. It seems specifying as a number takes
precedence.