• I can't bind number keys

    From Luc@21:1/5 to All on Sat May 13 07:32:41 2023
    I can't seem to bind any number keys on the top row. The number keys on
    the numeric keypad work, but the top row keys won't.

    What is going on? Some Linux limitation?

    Example code:


    package require Tk
    wm withdraw .
    toplevel .top -background #c0c0c0

    ttk::treeview .top.tree -columns {} -yscrollcommand {.top.vbar set} ttk::scrollbar .top.vbar -orient vertical -command {.top.tree yview}

    grid .top.tree -row 0 -column 0 -sticky nsew
    grid .top.vbar -row 0 -column 1 -sticky ns
    grid columnconfigure . 0 -weight 1
    grid rowconfigure . 0 -weight 1

    .top.tree insert {} end -id root1 -text "Root 1"
    .top.tree insert {} end -id root2 -text "Root 2"
    .top.tree insert root2 end -id subroot1 -text "Sub Root 1"
    .top.tree insert {} end -id root3 -text "Root 3"

    focus .top.tree
    .top.tree focus root1

    # this works with or without Alt
    bind .top.tree <KP_1> {puts "bang!"}
    # this won't work at all
    bind .top.tree <1> {puts "bang!"}


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to Luc on Sat May 13 13:14:22 2023
    On 13/05/2023 12:32, Luc wrote:
    # this works with or without Alt
    bind .top.tree <KP_1> {puts "bang!"}
    # this won't work at all
    bind .top.tree <1> {puts "bang!"}

    It works. It just doesn't do what you think. Compare the two:
    % bind foo <1> #
    % bind foo <KP_1> #
    % bind foo
    <Key-KP_1> <Button-1>

    If you omit the event type, Tk picks the most likely one.


    Schelte.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to All on Sat May 13 15:25:21 2023
    Try:

    bind .top.tree

    The full details of the events bound to .top.tree are returned.
    You can see what <1> actually means to bind.

    See the EVENT DETAILS section of the bind man page too.
    This specific case is given as an example.

    Dave B

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Sat May 13 14:23:42 2023
    Luc <[email protected]d> wrote:
    I can't seem to bind any number keys on the top row. The number keys on
    the numeric keypad work, but the top row keys won't.

    What is going on? Some Linux limitation?

    No.

    bind .top.tree <1> {puts "bang!"}

    From the bind man page, in the "Event Details" section:

    If a button number is given then type may be omitted: if will
    default to ButtonPress. For example, the specifier <1> is
    equivalent to <ButtonPress-1>.

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