0
我想要綁定一個對象,當鼠標指針位於它上面時突出顯示。如何使用鼠標指針在tcl/tk上突出顯示一個對象?
.c bind $object <Enter> [list %W itemconfigure $object -width 4]
但是,如何在鼠標指針離開時自動切換到上一階段?
我想要綁定一個對象,當鼠標指針位於它上面時突出顯示。如何使用鼠標指針在tcl/tk上突出顯示一個對象?
.c bind $object <Enter> [list %W itemconfigure $object -width 4]
但是,如何在鼠標指針離開時自動切換到上一階段?
可以調用這個子程序幾次終止此操作:
proc highlightView {object} {
.c bind $object <Enter> [list %W itemconfigure $object -width 4]
.c bind $object <Leave> [list %W itemconfigure $object -width [.c itemcget $object -width]]
}
你可以改變顏色使用選項-fill
突出對象:
proc highlightView {object} {
.c bind $object <Enter> [list %W itemconfigure $object -fill red]
.c bind $object <Leave> [list %W itemconfigure $object -fill [.c itemcget $object -fill]]
}
可以綁定<Leave>
事件不做任何變更:
.c bind $object <Leave> [list %W itemconfigure $object -width 1]
如果你有多種線寬的對象,那麼你需要在一些地方保存先前的寬度或<Leave>
事件與適當的寬度綁定:
.c bind $object <Enter> [subst {
%W bind <Leave> [list %W itemconfigure $object -width [%W itemcget -width]]
%W itemconfigure $object -width 4
}]
由於Tk的保證最多隻有一個帆布產品電流(即,已經''ED),只是存儲在一個全球性的價值變量就足夠了。 –
2014-10-28 09:26:31
謝謝Slebetman先生,經過一些修改後正在工作。但是你的想法非常有用。 – 2014-10-28 09:56:44