Re: How to get a Tk widget's coordinate? How to judge mouse is on a widget or not?



"suchenwi" <richard.suchenwirth-bauersachs@xxxxxxxxxxx> writes:

mengrufeng@xxxxxxxxx schrieb:

How to get a Tk widget's coordinate? How to judge mouse is on a widget
or not?

For coordinates, use [winfo geometry $widget] which returns
(width)x(height)+(deltax)+(deltay)
The delta coordinates are relative to its parent window.
For toplevels, [wm geometry $widget] gives the location relative to the
screen in the same format.
When the mouse pointer enters or leaves a widget, <Enter> resp. <Leave>
events are generated. Just bind to them if you want to be notified.
Little example:

pack [button .b -text hello -relief flat]
bind .b <Enter> {.b config -relief raised}
bind .b <Leave> {.b config -relief flat}

Another thing, on some systems there is [winfo pointerx] and y,
so you can determine which widget contains the mouse pointer by

winfo containing [winfo pointerx] [winfo pointery]


--
Donald Arseneau asnd@xxxxxxxxx
.