Re: How to get a Tk widget's coordinate? How to judge mouse is on a widget or not?
- From: Donald Arseneau <asnd@xxxxxxxxx>
- Date: 14 Jul 2006 05:38:07 -0700
"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
.
- Follow-Ups:
- Re: How to get a Tk widget's coordinate? How to judge mouse is on a widget or not?
- From: Donald Arseneau
- Re: How to get a Tk widget's coordinate? How to judge mouse is on a widget or not?
- References:
- Prev by Date: aqua needs help to trigger events
- Next by Date: Re: Another parser question
- Previous by thread: Re: How to get a Tk widget's coordinate? How to judge mouse is on a widget or not?
- Next by thread: Re: How to get a Tk widget's coordinate? How to judge mouse is on a widget or not?
- Index(es):