Menu

#938 Event binding bug where events are not triggerd when then sh

obsolete: 8.4a1
closed-invalid
69. Events (88)
5
2003-11-13
2000-11-01
No

OriginalBugID: 6217 Bug
Version: 8.4a1
SubmitDate: '2000-09-06'
LastModified:
Severity: MED
Status: UnAssn
Submitter: techsupp
OS: Windows 98
OSVersion: Microsoft Windows 98
Machine: Pentium III 600EB

Name:
Mark Murawski

Extensions:
none

CustomShell:
none

Comments:
This dosnt bug dosnt seem to exist in unix/linux, but yet, i only tested
this with one window manager. And I have no idea about mac, since I dont
own or have access to one.

ReproducibleScript:
commandline: wish tclbug.tcl

A canvas is set up to contain a red square withen the canvas when moved, and then when the mouse is released from dragging, put the square back in its origional position. Drag the square so that your mouse cursor is off of the canvas, then click the RIGHT mouse button in the parent tk window while still holding the left mouse button, now release both buttons. What happens? The square is stuck there, because the release event was not triggered

Third parties have verified this bug
# ----code----

pack [text .text -wrap word -height 6]

.text insert end "Tk canvas or event binding bug:\nThis canvas is set up to contain the red square withen the canvas when moved, and then when the mouse is released from dragging, put the square back in its origional position. Drag the square so that your mouse cursor is off of the canvas, then click the RIGHT mouse button in the parent tk window while still holding the left mouse button, now release both buttons. What happens? The square is stuck there, because the release event was not triggered"

set w .canvas
pack [canvas $w -width 450 -height 200] -padx 10 -pady 10
set image [$w create rec 50 50 100 100 -fill red]

pack [text .echo -height 2 -width 80 -height 10] -expand 1 -fill y

proc echo {text} {
.echo insert end "$text\n"
.echo see end
}

$w bind $image <B1-Motion> [list mouse move $image %x %y]
$w bind $image <B1-ButtonRelease-1> [list mouse release $image %x %y]

proc mouse {type item x y} {
set w .canvas

switch -- $type {
move {
set coords [$w coords $item]

set x2 [lindex $coords 2]
set y2 [lindex $coords 3]

set cx [winfo width $w]
set cy [winfo height $w]

if {$x < 0} {set x 0}
if {$y < 0} {set y 0}

set x2 [expr $x + 50]
set y2 [expr $y + 50]

if {[expr $x + 50] > $cx} {set x2 $cx; set x [expr $x2 - 50]}
if {[expr $y + 50] > $cy} {set y2 $cy; set y [expr $y2 - 50]}

$w coords $item $x $y $x2 $y2
return
}
release {
echo "mouse release!"
$w coords $item 50 50 100 100
}
}
}

ObservedBehavior:
The undesirable behavior is that the <B1-ButtonRelease-1> event is not triggered in any manner.

DesiredBehavior:
The square will not return to its origional position that would have been handled by <B1-ButtonRelease-1>. Since <B1-ButtonRelease-1> is not triggered, the square will remain in the last position before the mouse buttons were released

Discussion

  • Donal K. Fellows

    • labels: 104343 --> 69. Events
     
  • Don Porter

    Don Porter - 2003-11-12
    • assigned_to: nobody --> dkf
    • summary: Event binding bug where events are not triggerd when then should. --> Event binding bug where events are not triggerd when then sh
     
  • Donal K. Fellows

    • status: open --> closed
     
  • Donal K. Fellows

    • status: closed --> closed-invalid
     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    Pilot Error: Use <ButtonRelease-1>, not <B1-ButtonRelease-1>
    (button 1 released while button 1 pressed? Erk!)