• Re: get bind information in bound script

    From nemethi@21:1/5 to All on Wed Jan 17 18:02:27 2024
    Am 17.01.24 um 00:26 schrieb Manfred Rosenberger:
    listbox .lb -width 30
    pack .lb
    .lb insert 1 "Element 1"
    .lb insert 2 "Element 2"
    .lb insert 3 "Element 3"

    proc handleSelection {s T} {
    # Greife auf den aktuellen Text des ausgewählten Elements in der Listbox zu
    set selectedIndex [.lb curselection]
    if {$selectedIndex ne ""} {
    set selectedText [.lb get $selectedIndex]
    # Gib das ausgewählte Element und den Ereignistyp in der Konsole aus
    puts "eventState: $s"
    puts "eventType: $T <- [lindex [event info] $T]"
    puts "Ausgewähltes Element: $selectedText"
    }
    }
    bind .lb <<ListboxSelect>> [list handleSelection %W %s %T]

    =================

    eventState: 0
    eventType: 35 <-
    Ausgewähltes Element: Element 2

    ... what das 0 and 35 mean?
    ... if these numbers are indices of lists, what does this indices try to tell me?

    thanks in advance, Manfred

    The %T event field holds the event's type, like KeyPress, KeyRelease, ButtonPress, ButtonRelease, etc., where these numerical constants are
    defined in the file xlib/X11/X.h as follows:

    #define KeyPress 2
    #define KeyRelease 3
    #define ButtonPress 4
    #define ButtonRelease 5
    ...
    #define MappingNotify 34
    ...

    In case of a virtual event, the type is defined in the file generic/tk.h as

    #define VirtualEvent (MappingNotify + 1)

    which results in 35.

    The %s event field holds the state field from the event. For example,
    on my Linux box, for a pure ButtonPress event its value is 16 = 0x10,
    for ButtonPress with the Shift key down it is 17 = 0x11, and so on. For
    a virtual event like <<ListboxSelect>>, the state is set to 0.

    --
    Csaba Nemethi https://www.nemethi.de mailto:[email protected]

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