• Mysterious replacement of a binding

    From Helmut Giese@[email protected] to comp.lang.tcl on Wed Sep 3 21:39:39 2025
    From Newsgroup: comp.lang.tcl

    Hello out there,
    during the development of a GUI app I am using the tcltest package.
    But all of a sudden a certain binding disappears / is replaced. I
    traced it to the following test:
    ---
    test simeasy-4.10 {Test whether lines stay at their widgets moving all
    widgets} -body {
    # select all
    $C moveMouse 2 55 40 55 ""
    event generate $c <ButtonPress> -button 1 -state 5 -x 40 -y 55
    puts "a) Button 3: [$c bind [$wdgt3 set id] <Button-3>]"
    $C moveMouse 40 55 230 65 ""
    event generate $c <ButtonPress> -button 1 -state 5 -x 230 -y 65
    puts "a1) Button 3: [$c bind [$wdgt3 set id] <Button-3>]"
    $C moveMouse 230 65 30 130 ""
    event generate $c <ButtonPress> -button 1 -state 5 -x 30 -y 130
    puts "a2) Button 3: [$c bind [$wdgt3 set id] <Button-3>]"
    $C moveMouse 30 130 230 130 ""
    event generate $c <ButtonPress> -button 1 -state 5 -x 230 -y 130
    puts "a3) Button 3: [$c bind [$wdgt3 set id] <Button-3>]"
    ...
    }
    ---
    The output is
    ---- simeasy-4.10 start
    a) Button 3: ::oo::Obj3505::Pad1 startNewLineHL %x %y
    a1) Button 3: ::oo::Obj3505::Pad1 startNewLineHL %x %y
    a2) Button 3: ::oo::Obj3505::Pad1 catchClickHL
    a3) Button 3: ::oo::Obj3505::Pad1 catchClickHL

    It is a sequence of 'moveMouse / event generate <ButtonPress>'
    commands and looking at the output I am lost:
    - after the first sequence: ok
    - after the second sequence: still ok
    - after the third sequence (at puts "a2 .."): the binding has
    changed.

    How can this be? How can 'event generate' change a binding?
    Any ideas will be highly appreciated
    Helmut
    PS: 'moveMouse ' is a proc which divides the total distance into 10
    parts and and then does 10 smaller 'event generate <Motion>' commands.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Rich@[email protected] to comp.lang.tcl on Wed Sep 3 22:21:17 2025
    From Newsgroup: comp.lang.tcl

    Helmut Giese <[email protected]> wrote:
    How can this be? How can 'event generate' change a binding?

    The only idea I can suggest is that somewhere, a binding script
    contains itself a call to bind that is changing the binding.

    You might consider renaming the old bind to a new name and substuting
    one that prints out what is happening. I.e., something like this at
    global level:

    rename bind old_bind
    proc bind {args} {
    puts stderr "bind called with args=$args"
    old_bind {*}$args
    }

    Then see if somewhere there is a call to bind happening that is
    unexpected.

    If there is, then you can add to the bind proc some calls to info to
    print out stack level information and maybe figure out where the odd
    call is coming from.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Helmut Giese@[email protected] to comp.lang.tcl on Thu Sep 4 20:08:03 2025
    From Newsgroup: comp.lang.tcl

    Hello Rich,
    Helmut Giese <[email protected]> wrote:
    How can this be? How can 'event generate' change a binding?
    easyly: If this event is a button click and in the script being
    invoked happens exactly this. I am sorry, evidently it was too late
    yesterday for me.
    But your advice helped me still: On looking really close the
    misbehaviour revealed a rather severe design bug. So 'high five' to
    tcltest and many thanks to you.
    Helmut
    --- Synchronet 3.21a-Linux NewsLink 1.2