summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/menu.n15
-rw-r--r--tests/menu.test9
2 files changed, 16 insertions, 8 deletions
diff --git a/doc/menu.n b/doc/menu.n
index 6d0dc8a..1c943f9 100644
--- a/doc/menu.n
+++ b/doc/menu.n
@@ -285,15 +285,10 @@ operations on the widget. It has the following general form:
determine the exact behavior of the command.
.PP
Many of the widget commands for a menu take as one argument an
-indicator of which entry of the menu to operate on. These
+indicator of which entry of the menu to operate on. These
indicators are called \fIindex\fRes and may be specified in
any of the following forms:
.TP 12
-\fInumber\fR
-Specifies the entry numerically, where 0 corresponds
-to the top-most entry of the menu, 1 to the entry below it, and
-so on.
-.TP 12
\fBactive\fR
Indicates the entry that is currently active. If no entry is
active then this form is equivalent to \fBnone\fR. This form may
@@ -323,6 +318,11 @@ For example,
.QW \fB@0\fR
indicates the top-most entry in the window.
.TP 12
+\fInumber\fR
+Specifies the entry numerically, where 0 corresponds
+to the top-most entry of the menu, 1 to the entry below it, and
+so on.
+.TP 12
\fIpattern\fR
If the index does not satisfy one of the above forms then this
form is used. \fIPattern\fR is pattern-matched against the label of
@@ -330,6 +330,9 @@ each entry in the menu, in order from the top down, until a
matching entry is found. The rules of \fBTcl_StringMatch\fR
are used.
.PP
+If the index could match more than one of the above forms, then
+the form earlier in the above list takes precedence.
+.PP
The following widget commands are possible for menu widgets:
.TP
\fIpathName \fBactivate \fIindex\fR
diff --git a/tests/menu.test b/tests/menu.test
index 3cb47c3..cfe00b9 100644
--- a/tests/menu.test
+++ b/tests/menu.test
@@ -754,8 +754,13 @@ test menu-3.41 {MenuWidgetCmd procedure, "index" option} {
catch {destroy .m1}
menu .m1
.m1 add command -label "test"
- list [catch {.m1 index "test"} msg] $msg [destroy .m1]
-} {0 1 {}}
+ .m1 add command -label "3"
+ .m1 add command -label "another label"
+ .m1 add command -label "end"
+ .m1 add command -label "3a"
+ .m1 add command -label "final entry"
+ list [.m1 index "test"] [.m1 index "3"] [.m1 index "3a"] [.m1 index "end"] [destroy .m1]
+} {1 3 5 6 {}}
test menu-3.42 {MenuWidgetCmd procedure, "insert" option} {
catch {destroy .m1}
menu .m1