3 #----- general machinery -----
9 tktray::icon .i -class example
10 .i configure -docked 1
18 proc pressed {b x y} {
22 puts "unpost $posted toggle"
25 } elseif {[winfo exists .m$b]} {
28 puts "unpost $posted other"
41 bind .i <ButtonPress> { pressed %b %X %Y }
43 proc tooltip_starttimer {state x y} {
44 global tooltip_after posted tooltip_inwindow
45 if {$state || $posted || !$tooltip_inwindow} { tooltip_cancel; return }
46 catch { after cancel $tooltip_after }
47 set tooltip_after [after 500 tooltip_show $x $y]
50 proc tooltip_cancel {} {
52 catch { after cancel $tooltip_after }
53 catch { unset $tooltip_after }
57 set tooltip_inwindow 0
59 proc tooltip_enter {state x y} {
60 global tooltip_inwindow
61 set tooltip_inwindow 1
62 tooltip_starttimer $state $x $y
65 proc tooltip_leave {} {
66 global tooltip_inwindow
67 set tooltip_inwindow 0
71 proc setuptooltip {} {
72 bind .i <Enter> { tooltip_enter %s %X %Y }
73 bind .i <Leave> { tooltip_leave }
74 bind .i <ButtonRelease> { tooltip_cancel; tooltip_starttimer %s %X %Y }
75 bind .i <Motion> { tooltip_starttimer %s %X %Y }
76 toplevel .tt -background black
78 wm overrideredirect .tt 1
79 label .tt.t -justify left -background {#EEE1B3}
80 pack .tt.t -padx 1 -pady 1
85 .tt.t configure -text $s
88 proc tooltip_show {x y} {
91 wm geometry .tt +$x+$y
95 proc setimage {image} {
96 .i configure -image $image
99 #----- specifics -----
101 .m1 add command -command { msel; puts hi } -label hi
102 .m3 add command -command { msel; puts boo } -label boo
104 image create bitmap ims -file /usr/share/ghostscript/8.71/lib/gs_s.xbm
108 settooltip "line\nanother"