| Description: |
Trying to use the new -topmost option of wm attributes,
a typical application would be to post a new "Always on
Top" menu option in the windows system menu (see
code below). However, when running this code and
selecting the "Always on Top" option, the menu choice
disappears! If I replace the wm -topmost command with
one from a custom dll that does the same thing, the
menu option stays as expected.
There is some interaction with the topmost command
and system menu.
#---Demo Code below ---------------------------------------
proc pinOnSystemMenu {M W} {
if {$M=={}} {
set M $W.menubar
menu $M -tearoff 0
$W config -menu $M
}
$M add cascade -label System -font menu -menu
$M.system
menu $M.system -tearoff 0
set ::TA($W,pinned) 0
$M.system add separator
$M.system add checkbutton -label "Always on Top" \
-variable ::TA($W,pinned) \
-command "control $W \$::TA($W,pinned)"
}
proc control {win how} {
wm attributes $win -topmost $how
}
proc state {win} {
return [wm attributes $win -topmost]
}
wm withdraw .
toplevel .test
wm protocol .test WM_DELETE_WINDOW {exit}
;##
;# Play with system menu, the option will disappear
when selected.
;#
pinOnSystemMenu {} .test
|