Tk Source Code

View Ticket
Login
Ticket UUID: 1185793
Title: extra event called in windows
Type: Bug Version: obsolete: 8.4.9
Submitter: lio_lion Created on: 2005-04-19 09:48:18
Subsystem: 69. Events Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Open Last Modified: 2026-09-23 13:09:16
Resolution: None Closed By:
    Closed on:
Description:
I am using Tcl/Tk 8.4.4.0 (from Activestate) however
could not find any documentation to say that this has
been fixed. I am running Windows 2000, and believe this
bug does not occur in Linux (no idea about Mac).

Basically an extra <Enter> event is called after a
tk_popup menu is posted due to a mouseclick event.
Below is a short list of how to reproduce 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.

PS I searched and couldn't find this bug in the bugs.
It appears to be the reverse of bug 873655.

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
User Comments: serhiy.storchaka added on 2026-09-23 13:09:16:

The spurious crossing events are reproducible on Windows 11 with 9.1b1 and are fixed by [b8e2b73fd5] in branch win-popup-phantom-events (ticket [869305]): while the popup is posted, main sends Leave/Enter with state=256 to the tag and to the widget, the branch sends nothing until the pointer really leaves.

What remains on both is that the click which dismisses the menu is delivered to the widget under it — with the tag binding of this ticket it posts the menu again. A native context menu on Windows swallows that click. So the events of this ticket are fixed by the 869305 branch, but the leaked click needs a separate fix.


lio_lion added on 2005-04-26 13:13:25:
Logged In: YES 
user_id=971615

I upgraded to the latest version 8.4.9.0 (from Activestate)
and I still get this problem, so I am updating the group.

Lio