| Ticket UUID: | 2543460 | |||
| Title: | Enter/Leave cnv events not reported while mouse btn is down | |||
| Type: | Bug | Version: | 8.5.6, 8.6.18, 9.0.5, 9.1b1 | |
| Submitter: | mescalinum | Created on: | 2009-01-28 17:11:34 | |
| Subsystem: | 04. Canvas Basics | Assigned To: | hobbs | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Pending | Last Modified: | 2026-09-22 12:05:00 | |
| Resolution: | Wont Fix | Closed By: | ||
| Closed on: | ||||
| Description: |
consider this little testcase:
pack [canvas .c -width 300 -height 190 -background white]
# two test items
.c create rectangle 20 30 40 50 -tags red -fill red
.c create rectangle 80 30 100 50 -tags black -fill black
# text items for showing what's happening
.c create text 20 90 -text {red: } -tags txt1 -anchor nw
.c create text 20 120 -text {tags: } -tags txt2 -anchor nw
# bind <Enter> and <Leave>
.c bind red <Enter> {.c itemconfigure txt1 -text red:\ Enter}
.c bind red <Leave> {.c itemconfigure txt1 -text red:\ Leave}
# the workaround: (this fails too)
bind .c <Motion> {.c itemconfigure txt2 -text tags:\ [.c gettags [.c find withtag current]]}
# not really needed for this testcase:
bind .c <ButtonPress> {.c configure -background red}
bind .c <ButtonRelease> {.c configure -background white}
item with 'red' tag is bound to <Enter> and <Leave> events.
but it works only when the bouse button are not pressed.
if you click in the white area and drag over the red item, it won't send the <Enter>/<Leave> events.
in addition, an attempt to workaround this issue by using [.canvas find withtag current&&$myTag] would fail too, because tag 'current' is not updated while mouse button is down.
I don't know if this is expected, or not.
reading the manual of canvas I'd expect 'current' tag and <Enter>/<Leave> events to work in any condition.
I'm not filing a bug about documentation though.
I'd rather want those things working (perhaps enabled by some exotic [canvas] option), because a full workaround on this issue implies various nested loops, to track position and retrieve all the tags, and match them, and other than awful, I think it could turn into a performance hog.
Best regards
| |||
| User Comments: |
serhiy.storchaka added on 2026-09-22 12:05:00:
This is not specific to canvas items: it is the implicit grab of the window system, which the canvas imitates. While a mouse button is pressed, all events go to the item (or window) on which the button was pressed, so the pointer entering another item generates no <Enter> event and does not change the "current" tag until the release. The same happens with ordinary widgets. Pressing on one frame and dragging onto another one on X11 gives "Leave .a" at once, and only at the release "Leave .a" again and "Enter .b" (the crossing events of the ungrab); canvas items generate the same sequence, with the "current" tag changing at the release. Verified with 8.6.18, 9.0.5 and 9.1. An option to track the current item during a drag would need a TIP. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki