• bind

    From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Mon Apr 7 18:51:42 2025
    From Newsgroup: comp.lang.tcl

    Hi

    I have a small script.

    #### script start

    toplevel .top
    pack [frame .top.f]
    pack [entry .top.f.en]
    bind .top <Button-1> "tuwas b1 %W"
    bind .top <Down> "tuwas down %W"

    proc tuwas {cmd W} {
    puts "$cmd : $W"

    if {$W ne ".top.f"} {
    if {$cmd eq "b1"} {event generate .top.f <Button-1> }
    if {$cmd eq "down"} {event generate .top.f <Down> }
    }

    }

    #### script end

    If I press the mouse-button on .top.f.en I get two outputs:
    b1 : .top.f.en
    b1 : .top.f

    That's was I expected.

    If I on .top.f.en and I press <Down> I get many (501) outputs:
    down : .top.f.en
    down : .top.f.en
    down : .top.f.en

    I get an error: "error: too many nested evaluations (infinite loop?)"


    I expected I get:
    down : .top.f.en
    down : .top.f

    If I press <Down> on .top.f the proc tuwas should generate a event on
    .top.f not on .top.f.en

    Why this different behavior?
    What do I wrong?

    reagards

    Manfred



    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Mon Apr 7 19:15:55 2025
    From Newsgroup: comp.lang.tcl

    Am 07.04.2025 um 18:51 schrieb Manfred Stelzhammer:
    Hi

    I have a small script.

    #### script start

    toplevel .top
    pack [frame .top.f]
    pack [entry .top.f.en]
    bind .top <Button-1> "tuwas b1 %W"
    bind .top <Down> "tuwas down %W"

    proc tuwas {cmd W} {
        puts "$cmd : $W"

        if {$W ne ".top.f"} {
            if {$cmd eq "b1"} {event generate .top.f <Button-1> }
            if {$cmd eq "down"} {event generate .top.f <Down> }
        }

    }

    #### script end

    If I press the mouse-button on .top.f.en I get two outputs:
        b1 : .top.f.en
        b1 : .top.f

    That's was I expected.

    If I on .top.f.en and I press <Down> I get many (501) outputs:
        down : .top.f.en
        down : .top.f.en
        down : .top.f.en

    I get an error: "error: too many nested evaluations (infinite loop?)"


    I expected I get:
        down : .top.f.en
        down : .top.f

    If I press <Down> on .top.f the proc tuwas should generate a event
    on .top.f not on .top.f.en

    Why this different behavior?
    What do I wrong?

    reagards

    Manfred




    Consider to use "break" as last command of your binding script.
    This avoids to call any following binding scripts.

    Harald

    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Mon Apr 7 19:29:22 2025
    From Newsgroup: comp.lang.tcl

    Thanks

    I changed the script:

    ##
    proc tuwas {cmd W} {
    puts "$cmd : $W"

    if {$W ne ".top.f"} {
    if {$cmd eq "b1"} {event generate .top.f <Button-1> }
    if {$cmd eq "down"} {
    event generate .top.f <KeyPress-Down>
    break

    }

    }

    }
    ##

    But it doesn't change anything.


    reagards

    Manfred

    Am 07.04.25 um 19:15 schrieb Harald Oehlmann:
    Consider to use "break" as last command of your binding script.
    This avoids to call any following binding scripts.

    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Manfred Stelzhammer@manfred@antispam.at to comp.lang.tcl on Mon Apr 7 21:13:25 2025
    From Newsgroup: comp.lang.tcl

    Hi

    Now I found the solution:

    I added a "focus .top.f".
    Now it works like expected.

    proc tuwas {K W} {
    puts "$K : $W"

    if {$W ne ".top.f"} {
    if {$K eq "b1"} {
    event generate .top.f <Button-1>
    }
    if {$K eq "Down"} {
    focus .top.f
    event generate .top.f <KeyPress-$K>



    }

    }
    }

    regards

    Manfred



    Am 07.04.25 um 19:29 schrieb Manfred Stelzhammer:
    Thanks

    I changed the script:

    ##
    proc tuwas {cmd W} {
        puts "$cmd : $W"

        if {$W ne ".top.f"} {
            if {$cmd eq "b1"} {event generate .top.f <Button-1> }
            if {$cmd eq "down"} {
                event generate .top.f  <KeyPress-Down>
                 break

            }

         }

    }
    ##

    But it doesn't change anything.


    reagards

    Manfred

    Am 07.04.25 um 19:15 schrieb Harald Oehlmann:
    Consider to use "break" as last command of your binding script.
    This avoids to call any following binding scripts.


    --- Synchronet 3.20c-Linux NewsLink 1.2