For Programmers: Free Programming Magazines  


Home > Archive > Tcl > April 2005 > tk event bug in windows









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author tk event bug in windows
lio

2005-04-18, 3:59 pm

I found what I believe is a bug in tk. It doesn't happen on every platform.
I am currently running Windows 2000 with Tcl/Tk 8.4.4.0 (from activestate).
I was wondering if anyone else has ever noticed this bug, if it has been
fixed at all, and on which systems people do or don't have this bug.

Now for the bug:
An <Enter> event as well as another event (eg left click) causing a tk_popup
is bound to text in a text widget.
Then move the mouse over the text -> Enter event triggered
Then click the mouse -> popup comes up
Then click an item in the popup, or deselect the popup by clicking somewhere
else on the screen -> Enter event triggered again.

This second enter event should not be triggered!!!!


A simple application which can show this in action is the 1 below, I have 2
text boxes, the first has some text with the bindings, the second is for
output when the events are triggered. I have 3 events, <Enter> <Leave> and
"left click". Try moving the mouse over the text, left click it, then click
somewhere entirely off the application (or in the bottom text window, etc).
The <Enter> event is triggered when it shouldn't have been, and the <Leave>
event does not get called until the mouse is moved over the top text box
again.

Thankyou in advance.
Lio.


Code:

text .input -width 20 -height 5
pack .input

text .input2 -width 20 -height 10
pack .input2

set x 0
..input tag bind bound <Enter> {
incr x
.input2 insert end "enter $x\n"
.input2 yview end
}
set l 0
..input tag bind bound <Leave> {
incr l
.input2 insert end "leave $l\n"
.input2 yview end
}
menu .amenu
..input tag bind bound <Button1-ButtonRelease> {
tk_popup .amenu %X %Y
}

..input insert end "some text" bound


Donald Arseneau

2005-04-20, 4:00 pm

"lio" <lio@home> writes:

> output when the events are triggered. I have 3 events, <Enter> <Leave> and
> "left click". Try moving the mouse over the text, left click it, then click
> somewhere entirely off the application (or in the bottom text window, etc).
> The <Enter> event is triggered when it shouldn't have been, and the <Leave>
> event does not get called until the mouse is moved over the top text box
> again.


I haven't seen anything wrong. Moreover, your description
doesn't necessarily mean anything was wrong for you. What
I get, and what is correct, is that clicking on the text
brings up the popup menu. The menu grabs focus so a "Leave"
message is printed. While the menu is up there are no messages,
even if I pass the mouse cursor over the text. When the menu
is dismissed, the focus is restored to the text that you clicked
on, and it registers "Enter". And immediately, if the pointer
is outside the text, it invokes "Leave".

If Tk didn't balance all Enter and Leave, it would be very
difficult to make use of such events.


--
Donald Arseneau asnd@triumf.ca
lio

2005-04-21, 4:00 am

> > output when the events are triggered. I have 3 events, <Enter> <Leave>
and
click[color=darkred]
etc).[color=darkred]
<Leave>[color=darkred]
>
> I haven't seen anything wrong. Moreover, your description
> doesn't necessarily mean anything was wrong for you. What
> I get, and what is correct, is that clicking on the text
> brings up the popup menu. The menu grabs focus so a "Leave"
> message is printed. While the menu is up there are no messages,
> even if I pass the mouse cursor over the text. When the menu
> is dismissed, the focus is restored to the text that you clicked
> on, and it registers "Enter". And immediately, if the pointer
> is outside the text, it invokes "Leave".
>
> If Tk didn't balance all Enter and Leave, it would be very
> difficult to make use of such events.


What operating system are you running? If what you say should happen happens
then I would be happy, however on my system after the window is dismissed it
register the "Enter" event as you say. However never registers the "Leave"
event until the mouse re-enters the text box that was clicked (ie if the
mouse is over a different text box, the "Leave" never occurs).

Lio.


Donald Arseneau

2005-04-21, 8:58 am

"lio" <lio@home> writes:

> What operating system are you running?


I tried it on Win XP (ActiveTcl) and Linux. But not with the
same Tcl version as you.


--
Donald Arseneau asnd@triumf.ca
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com