• default button appearance

    From saitology9@21:1/5 to All on Mon Oct 31 18:46:12 2022
    Hello,

    I have several buttons in a row and I would like one of the to be the
    default so that the Enter key will invoke it. The user can tab over to
    the other buttons to press Enter too.

    Normally, there is a slight visual cue to the default button. I tried "-default active", "-activebackground/-activeforeground", and several
    others.

    How do I achieve this?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to Rich on Mon Oct 31 22:07:21 2022
    On 10/31/2022 9:57 PM, Rich wrote:

    If you want a key to invoke it, then you probably need to shift focus
    to the button you want to be the default. Look up the 'focus' command.

    But the default Tk bindings invoke the focused button using space, not
    Enter, so you might also need to add a binding to the Enter key.


    My mistake: I should have said space not Enter.

    Look up the default Tk bindings for buttons and see how Tk does the
    space bar binding, you can copy that one and connect it to Enter.

    My question was not about the behavior which works just fine. Rather my question was that on my buttons, there is no visual indication as to
    which one would be invoked if I hit the space bar. [focus] on the frame
    or the any of buttons themselves doesn't seem to provide any visual clue.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to [email protected] on Tue Nov 1 01:57:38 2022
    saitology9 <[email protected]> wrote:
    Hello,

    I have several buttons in a row and I would like one of the to be the
    default so that the Enter key will invoke it. The user can tab over to
    the other buttons to press Enter too.

    Normally, there is a slight visual cue to the default button. I tried "-default active", "-activebackground/-activeforeground", and several
    others.

    How do I achieve this?

    If you want a key to invoke it, then you probably need to shift focus
    to the button you want to be the default. Look up the 'focus' command.

    But the default Tk bindings invoke the focused button using space, not
    Enter, so you might also need to add a binding to the Enter key.

    Look up the default Tk bindings for buttons and see how Tk does the
    space bar binding, you can copy that one and connect it to Enter.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to Rich on Mon Oct 31 22:14:24 2022
    On 10/31/2022 9:57 PM, Rich wrote:

    Look up the default Tk bindings for buttons and see how Tk does the
    space bar binding, you can copy that one and connect it to Enter.


    tk_dialog provides the visual clue I am talking about but [info body] on
    it does not return anything.


    # look at the yes button
    package req Tk
    tk_dialog .foo "The Title" "Do you want to say yes?" \
    questhead 0 " Yes " " No " " I'm not sure "

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to Rich on Mon Oct 31 22:16:32 2022
    On 10/31/2022 9:57 PM, Rich wrote:

    Look up the default Tk bindings for buttons and see how Tk does the
    space bar binding, you can copy that one and connect it to Enter.

    [info body] does return something to study. Thanks!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to Rich on Mon Oct 31 23:53:41 2022
    On 10/31/2022 11:29 PM, Rich wrote:

    X11/Linux/8.6.11:

    $ rlwrap wish
    % foreach i {1 2 3 4 5} { button .b$i -text .b$i ; pack .b$i -side left }
    % focus .b4

    When I hover over the window (I have Fvwm2 set for 'focus follows
    mouse' mode) button .b4 has a darker border (and if I hit space while
    the window is focused, button 4 is pressed).

    See https://postimg.cc/Js4HD3VV


    Thank you very much for the follow up. I reviewed the implementation of tk_dialog and found out that the trick was to include [tkwait
    visibility] right before doing any [focus] commands on the buttons.
    Along with "-default active" option. Then the visual appearance
    properly indicates which button is the default. Haven't tested it on Linux.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to [email protected] on Tue Nov 1 03:29:49 2022
    saitology9 <[email protected]> wrote:
    On 10/31/2022 9:57 PM, Rich wrote:

    If you want a key to invoke it, then you probably need to shift focus
    to the button you want to be the default. Look up the 'focus' command.

    But the default Tk bindings invoke the focused button using space, not
    Enter, so you might also need to add a binding to the Enter key.


    My mistake: I should have said space not Enter.

    Look up the default Tk bindings for buttons and see how Tk does the
    space bar binding, you can copy that one and connect it to Enter.

    My question was not about the behavior which works just fine. Rather my question was that on my buttons, there is no visual indication as to
    which one would be invoked if I hit the space bar. [focus] on the frame
    or the any of buttons themselves doesn't seem to provide any visual clue.

    X11/Linux/8.6.11:

    $ rlwrap wish
    % foreach i {1 2 3 4 5} { button .b$i -text .b$i ; pack .b$i -side left }
    % focus .b4

    When I hover over the window (I have Fvwm2 set for 'focus follows
    mouse' mode) button .b4 has a darker border (and if I hit space while
    the window is focused, button 4 is pressed).

    See https://postimg.cc/Js4HD3VV

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