Re: Binding to menu entry - not just to menu(-tree)
- From: Donald Arseneau <asnd@xxxxxxxxx>
- Date: 17 Jan 2007 18:54:14 -0800
"Zbigniew B." <Zbigniew@xxxxxxxxxxxxxxxxx> writes:
Of course I would to setup such help for all menus - and so I must bind the
same event to several different paths, like:
bind .menubar.help.menu <<MenuSelect>> {showHelp %W}
bind .menubar.edit.menu <<MenuSelect>> {showHelp %W}
...and so on.
Found an explanation in man: "It is possible for several bindings to match a
given X event.". I'm just not sure: does there exist any limit? Does it have
any (significant) influence on the load? Can I make - let's say - 9 such
bindings "quite safely"?
This is not what that bit of help was referring to. It refers to
cases like
bind .menubar.help.menu <Key> {foo}
bind .menubar.help.menu <Key-H> {bar}
bind Menu <Key> {baz}
where all three match when you type H. The first two both have the
same tag, so only the <Key-H> binding will fire, because it is more
specific. The Menu binding will also fire because it has a separate
tag (use [bindtags .menubar.help.menu] to see the list of tags).
proc showHelp {w} {
if { [$w index active] != "none" } {
if { [$w index active] > 0 } {
set chosen [.menubar.help.menu entrycget active -label]
.statusBar.lab config -text $helptext($chosen)
}
} else {
.statusBar.lab config -text ""
}
You can simpligy the handling of "none" by using the raw entry index
as the index to helptext, and setting
set ::helptext(none) ""
set ::helptext(1) "..."
(I generally use a -textvariable instead of .statusBar.lab config )
If you are making context help for all (or most) menus you can use a
single [bind] command, and use helptext() lookup instead of most
programming, with entries like $::helptext($w,$chosen)
bind Menu <<MenuSelect>> {showHelp %W}
proc showHelp { w } {
set active [$w index active]
if { [string is integer $active] && $active > 0 } {
set chosen [.menubar.help.menu entrycget active -label]
set ::menuHelpText $::helptext($w,$chosen)
} else {
set ::menuHelpText ""
}
}
set helptext(.menubar.help.menu,foo) "Help for foo in menubar.help"
Donald Arseneau asnd@xxxxxxxxx
.
- Follow-Ups:
- Re: Binding to menu entry - not just to menu(-tree)
- From: Ralf Fassel
- Re: Binding to menu entry - not just to menu(-tree)
- References:
- Binding to menu entry - not just to menu(-tree)
- From: Zbigniew B.
- Re: Binding to menu entry - not just to menu(-tree)
- From: Donald Arseneau
- Re: Binding to menu entry - not just to menu(-tree)
- From: Bryan Oakley
- Re: Binding to menu entry - not just to menu(-tree)
- From: Donald Arseneau
- Re: Binding to menu entry - not just to menu(-tree)
- From: Ralf Fassel
- Re: Binding to menu entry - not just to menu(-tree)
- From: Zbigniew B.
- Re: Binding to menu entry - not just to menu(-tree)
- From: Bryan Oakley
- Re: Binding to menu entry - not just to menu(-tree)
- From: Zbigniew B.
- Binding to menu entry - not just to menu(-tree)
- Prev by Date: Re: list or not a list?
- Next by Date: Problem doing fraction comparison in TCL
- Previous by thread: Re: Binding to menu entry - not just to menu(-tree)
- Next by thread: Re: Binding to menu entry - not just to menu(-tree)
- Index(es):
Relevant Pages
|