• How do I press a button with mouse right-clicks?

    From Luc@21:1/5 to All on Sun May 28 20:22:03 2023
    When I click a Tk button with the left mouse button, the Tk button
    "sinks" briefly to indicate that is has been pressed.

    I can bind different actions to left and right mouse button clicks,
    but Tk buttons won't "sink" when I right-click them.

    How can I add that effect to clicks with the right mouse button?

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Heller@21:1/5 to luc@sep.invalid on Mon May 29 01:42:08 2023
    Somewhere in your Tk install should be a file named button.tcl (on my Arm64 system running Debian, it is in /usr/share/tcltk/tk8.6/). Look in this file for the exact binding "magic" used to create the 3D "animation" effect you are seeing.

    At Sun, 28 May 2023 20:22:03 -0300 Luc <luc@sep.invalid> wrote:


    When I click a Tk button with the left mouse button, the Tk button
    "sinks" briefly to indicate that is has been pressed.

    I can bind different actions to left and right mouse button clicks,
    but Tk buttons won't "sink" when I right-click them.

    How can I add that effect to clicks with the right mouse button?


    --
    Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
    Deepwoods Software -- Custom Software Services
    http://www.deepsoft.com/ -- Linux Administration Services
    heller@deepsoft.com -- Webhosting Services

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Mon May 29 03:15:27 2023
    Luc <luc@sep.invalid> wrote:
    When I click a Tk button with the left mouse button, the Tk button
    "sinks" briefly to indicate that is has been pressed.

    I can bind different actions to left and right mouse button clicks,
    but Tk buttons won't "sink" when I right-click them.

    How can I add that effect to clicks with the right mouse button?

    In addition to Robert's suggestion, which you should do, the default
    bindings can be illuminating, you can introspect Tk to find out what a
    specific binding does:

    $ rlwrap wish
    % button .b
    .b
    % winfo class .b
    Button
    % bind Button
    <ButtonRelease-1> <Button-1> <Leave> <Enter> <<Invoke>> <Key-space>
    % bind Button <Button-1>

    tk::ButtonDown %W

    % info args tk::ButtonDown
    w
    % info body tk::ButtonDown

    variable ::tk::Priv

    # Only save the button's relief if it does not yet exist. If there
    # is an overrelief setting, Priv($w,relief) will already have been set,
    # and the current value of the -relief option will be incorrect.

    if {![info exists Priv($w,relief)]} {
    set Priv($w,relief) [$w cget -relief]
    }

    if {[$w cget -state] ne "disabled"} {
    set Priv(buttonWindow) $w
    $w configure -relief sunken
    set Priv($w,prelief) sunken

    # If this button has a repeatdelay set up, get it going with an after
    after cancel $Priv(afterId)
    set delay [$w cget -repeatdelay]
    set Priv(repeated) 0
    if {$delay > 0} {
    set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
    }
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mole Cool@21:1/5 to All on Tue May 30 14:15:39 2023
    Configure relief to be sunken :-)

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