button-release events get lost when target window is destroyed 
Author Message
 button-release events get lost when target window is destroyed

Tk 8.3 Bug:  Generated by Ajuba's bug entry form at
Responses to this post are encouraged.

Submitted by:  Jonas Beskow
OperatingSystem:  Linux-Red Hat
OperatingSystemVersion:  redhat 6.0
Machine:  dell precision 410
Synopsis:  button-release events get lost when target window is destroyed

toplevel .x
pack [label .x.l -text "double-click me!"]

bind .x.l <Double-Button-1> [list destroy .x]
bind . <B1-Motion> {puts "B1-Motion event"}

# run the above lines, double-click on the label
# when the labe-window goes away, move pointer over main window with no button pressed

B1-motion events are fired when no button is pressed

B1-motion events should not fire when no button is pressed

    This bug was introduced in tk 8.3 and is also present 8.4a1. There is a
    passage at the top of Tk_HandleEvent() that seems to be responsible
    (when it is commented out, the errant behavoiur goes away):

         * Hack for simulated X-events: Correct the state field
         * of the event record to match with the ButtonPress
         * and ButtonRelease events.

        if (eventPtr->type==ButtonPress) {
          dispPtr = TkGetDisplay(eventPtr->xbutton.display);
        eventPtr->xbutton.state |= dispPtr->mouseButtonState;
        switch (eventPtr->xbutton.button) {
            case 1: dispPtr->mouseButtonState |= Button1Mask; break;
            case 2: dispPtr->mouseButtonState |= Button2Mask; break;
            case 3: dispPtr->mouseButtonState |= Button3Mask; break;
        } else if (eventPtr->type==ButtonRelease) {
        dispPtr = TkGetDisplay(eventPtr->xbutton.display);
        switch (eventPtr->xbutton.button) {
            case 1: dispPtr->mouseButtonState &= ~Button1Mask; break;
            case 2: dispPtr->mouseButtonState &= ~Button2Mask; break;
            case 3: dispPtr->mouseButtonState &= ~Button3Mask; break;
        eventPtr->xbutton.state |= dispPtr->mouseButtonState;
        } else if (eventPtr->type==MotionNotify) {

        dispPtr = TkGetDisplay(eventPtr->xmotion.display);
        eventPtr->xmotion.state |= dispPtr->mouseButtonState;

Sun, 09 Mar 2003 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. I lost my minmize button on the window

2. Can't destroy widget without destroying window

3. Window Not Getting Events?

4. Seeing Button Events when outside a TK window.

5. Q: Button events seen by two overlapping windows

6. Wrong window getting mouse events

7. Problems generating mouse button events in X-Windows

8. I am searching for a VHDL PCI-Target description

9. Button Events and Tk Button w

10. Button Events and Tk Button widget

11. Button release in grabbed window

12. I am so COMPLETELY lost!


Powered by phpBB® Forum Software