Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

canvas: Why bind <Leave> throws error but <Button-1> not

30 views
Skip to first unread message

Horst Stanitzok

unread,
Jan 24, 2013, 7:41:40 AM1/24/13
to

What I get an error with <Leave> but not with <1> ?

Error:
"bad option "find": must be cget or configure"


The code:

pack [canvas .c]
.c create line 50 0 50 [.c cget -height] -tags aha -width 1 -fill red

bind . <Leave> {hair_delete %W %x} ;# error
#bind . <Button-1> {hair_delete %W %x} ;# OK

proc hair_delete {w x} {
if {[llength [$w find withtag aha]]} {
$w delete aha
}
}


Horst Stanitzok

unread,
Jan 24, 2013, 8:15:09 AM1/24/13
to
Sorry my mistake:

correct is:

bind .c <Leave>

not

bind . <Leave>



Horst

Arjen Markus

unread,
Jan 24, 2013, 8:15:12 AM1/24/13
to
I think you want to bind to .c instead of .

The error probably comes from the rules by which events are propagated
- <Leave> has a meaning for a toplevel widget, but <Button-1> does not.

Regards,

Arjen

Op donderdag 24 januari 2013 13:41:40 UTC+1 schreef Horst Stanitzok het volgende:

Uwe Klein

unread,
Jan 24, 2013, 8:03:53 AM1/24/13
to
debug by way of printing $w
proc hair_delete {w x} {
puts "win:$w"
> if {[llength [$w find withtag aha]]} {
> $w delete aha
> }
> }

my guess is you leave the toplevel.

anyway you explicitly bind to . and not .c"
the toplevel does not know about canvas subcomands.

uwe
0 new messages