• Modifiers in bindings suspend X's autorepeat

    From Luc@21:1/5 to All on Fri Mar 17 21:38:59 2023
    I've asked this before, but I didn't get any replies and searching
    really is not helping. So I decided to ask it differently:

    -----------------------------------
    set option 1
    set a 1

    package require Tk
    text .t
    pack .t
    .t insert end $a

    proc p.update {argUD} {
    global a
    if {$argUD == "up"} {
    incr a
    .t delete 1.0 end; .t insert end $a
    }
    if {$argUD == "down"} {
    incr a -1
    .t delete 1.0 end; .t insert end $a
    }
    }

    if {$option == 1} {
    bind . <KeyPress-Up> "p.update up"
    bind . <KeyPress-Down> "p.update down"
    }
    if {$option == 2} {
    bind . <Control_L><Up> "p.update up"
    bind . <Control_L><Down> "p.update down"
    }

    bind . <Alt_L><q> {exit 0}
    wm protocol . WM_DELETE_WINDOW {exit 0} -----------------------------------

    The script begins by setting "option" as 1. That means only the up
    and down arrow keys will be used to increase and decrease the counter.
    Note that if you press and hold either key, the counter display will
    increase or decrease, maybe very rapidly (that depends on your own
    keyboard speed/response settings).

    Please edit the script and change the first line so "option" becomes
    2. That means the new sets of keys to increase and decrease the
    counter is Control+up to increase and Control+down to decrease the
    counter. It works, but try pressing and holding Control once and
    continuously while pressing either arrow key repeatedly. That doesn't
    work for me. The keys will no longer respond after the first use, I
    have to release the modifier key before I can use that key combination
    again. It seems that modifiers have the power to momentarily suspend
    X's autorepeat mechanism.

    This is on Linux, of course.

    Is there a way to preserve the "rapid fire" with modifiers in Tk?


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dave bruchie@21:1/5 to All on Fri Mar 17 20:57:28 2023
    The important difference:
    <Control_L><Up> is the sequence: press left control followed by press Up <Control-Up> is press Up while holding control down, Control is a modifier, not a KeyPress event

    Dave B

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dave bruchie@21:1/5 to All on Fri Mar 17 20:43:35 2023
    # this code increments or decrements by 2 on each press of up or down
    # by 1 if control is held down while hitting up or down
    # Tcl/Tk 8.6.13 on Slackware 15-ish

    package require Tk

    destroy .t

    pack [text .t]

    proc wrtxt {x} {
    .t delete 1.0 end
    .t insert 1.0 $x
    }

    wrtxt [set a 1]

    bind .t <Control-KeyPress-Up> {wrtxt [incr a]}
    bind .t <Control-KeyPress-Down> {wrtxt [incr a -1]}

    bind .t <KeyPress-Up> {wrtxt [incr a 2]}
    bind .t <KeyPress-Down> {wrtxt [incr a -2]}

    # the event field separators should be white space or a dash, not sure about the _

    Dave B

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to dave bruchie on Sat Mar 18 14:19:58 2023
    On Fri, 17 Mar 2023 20:57:28 -0700 (PDT), dave bruchie wrote:

    The important difference:
    <Control_L><Up> is the sequence: press left control followed by press Up <Control-Up> is press Up while holding control down, Control is a
    modifier, not a KeyPress event

    Dave B


    OK. Thank you.

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)