• dialog focus

    From Mark Summerfield@m.n.summerfield@gmail.com to comp.lang.tcl on Fri Oct 10 06:07:23 2025
    From Newsgroup: comp.lang.tcl

    I have a Tcl/Tk 9 app with a main window and which sometimes
    pops up a modal toplevel window (e.g., a confirmation dialog).

    If I then switch to another application altogether, when I
    context switch back to my original app, the _main window_ gets
    the focus (even though the dialog is still there & even though
    I can't interact with the main window).

    I must then click the dialog to give it focus.

    Is it possible (1) to make the focus go automatically to the
    modal dialog if present? (2) to get the focus to the dialog
    via the keyboard?
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Fri Oct 10 09:58:35 2025
    From Newsgroup: comp.lang.tcl

    Am 10.10.2025 um 08:07 schrieb Mark Summerfield:
    I have a Tcl/Tk 9 app with a main window and which sometimes
    pops up a modal toplevel window (e.g., a confirmation dialog).

    If I then switch to another application altogether, when I
    context switch back to my original app, the _main window_ gets
    the focus (even though the dialog is still there & even though
    I can't interact with the main window).

    I must then click the dialog to give it focus.

    Is it possible (1) to make the focus go automatically to the
    modal dialog if present? (2) to get the focus to the dialog
    via the keyboard?

    grab -global $toplevel
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Mark Summerfield@m.n.summerfield@gmail.com to comp.lang.tcl on Fri Oct 10 09:37:12 2025
    From Newsgroup: comp.lang.tcl

    On Fri, 10 Oct 2025 09:58:35 +0200, Harald Oehlmann wrote:

    Am 10.10.2025 um 08:07 schrieb Mark Summerfield:
    I have a Tcl/Tk 9 app with a main window and which sometimes
    pops up a modal toplevel window (e.g., a confirmation dialog).

    If I then switch to another application altogether, when I
    context switch back to my original app, the _main window_ gets
    the focus (even though the dialog is still there & even though
    I can't interact with the main window).

    I must then click the dialog to give it focus.

    Is it possible (1) to make the focus go automatically to the
    modal dialog if present? (2) to get the focus to the dialog
    via the keyboard?

    grab -global $toplevel

    I never use grab -global because of the warning in the documentation: https://www.tcl-lang.org/man/tcl9.0/TkCmd/grab.html#M10
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From nab@user2230@newsgrouper.org.invalid to comp.lang.tcl on Fri Oct 10 12:18:16 2025
    From Newsgroup: comp.lang.tcl


    Mark Summerfield <m.n.summerfield@gmail.com> posted:

    I have a Tcl/Tk 9 app with a main window and which sometimes
    pops up a modal toplevel window (e.g., a confirmation dialog).

    If I then switch to another application altogether, when I
    context switch back to my original app, the _main window_ gets
    the focus (even though the dialog is still there & even though
    I can't interact with the main window).

    I must then click the dialog to give it focus.

    Is it possible (1) to make the focus go automatically to the
    modal dialog if present? (2) to get the focus to the dialog
    via the keyboard?

    Hi,
    for that purpose I use wigdet dialog from Tk Lib, and there's no issue like that.

    ++
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Christian Gollwitzer@auriocus@gmx.de to comp.lang.tcl on Fri Oct 10 14:28:05 2025
    From Newsgroup: comp.lang.tcl

    Am 10.10.25 um 08:07 schrieb Mark Summerfield:
    I have a Tcl/Tk 9 app with a main window and which sometimes
    pops up a modal toplevel window (e.g., a confirmation dialog).

    If I then switch to another application altogether, when I
    context switch back to my original app, the _main window_ gets
    the focus (even though the dialog is still there & even though
    I can't interact with the main window).

    I must then click the dialog to give it focus.

    Is it possible (1) to make the focus go automatically to the
    modal dialog if present? (2) to get the focus to the dialog
    via the keyboard?


    Look up wm transient https://www.tcl-lang.org/man/tcl8.4/TkCmd/wm.htm#M45

    Christian
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Rich@rich@example.invalid to comp.lang.tcl on Sat Oct 11 18:35:09 2025
    From Newsgroup: comp.lang.tcl

    Harald Oehlmann <wortkarg3@yahoo.com> wrote:
    Am 10.10.2025 um 08:07 schrieb Mark Summerfield:
    I have a Tcl/Tk 9 app with a main window and which sometimes
    pops up a modal toplevel window (e.g., a confirmation dialog).

    If I then switch to another application altogether, when I
    context switch back to my original app, the _main window_ gets
    the focus (even though the dialog is still there & even though
    I can't interact with the main window).

    I must then click the dialog to give it focus.

    Is it possible (1) to make the focus go automatically to the
    modal dialog if present? (2) to get the focus to the dialog
    via the keyboard?

    grab -global $toplevel

    While that would work, it would work by preventing any switching away
    from the dialog at all, even to an unrelated application. If you can't
    switch away at all, naturally you can't also lose focus. But a global
    grab is also a very poor UI design as it locks you into dismissing the
    dialog as your only choice, and that is why the warning is in the
    manpage about -global.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Rich@rich@example.invalid to comp.lang.tcl on Sat Oct 11 18:37:13 2025
    From Newsgroup: comp.lang.tcl

    Mark Summerfield <m.n.summerfield@gmail.com> wrote:
    I have a Tcl/Tk 9 app with a main window and which sometimes
    pops up a modal toplevel window (e.g., a confirmation dialog).

    If I then switch to another application altogether, when I
    context switch back to my original app, the _main window_ gets
    the focus (even though the dialog is still there & even though
    I can't interact with the main window).

    Sounds like either a window manager bug (switching away to another app
    and back are not Tk's responsibility). The window manager should be remembering the dialog was present and had focus at the switch away,
    and returning the focus to the dialog when switching back.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Christian Gollwitzer@auriocus@gmx.de to comp.lang.tcl on Sun Oct 12 07:58:46 2025
    From Newsgroup: comp.lang.tcl

    Am 11.10.25 um 20:37 schrieb Rich:
    Mark Summerfield <m.n.summerfield@gmail.com> wrote:
    I have a Tcl/Tk 9 app with a main window and which sometimes
    pops up a modal toplevel window (e.g., a confirmation dialog).

    If I then switch to another application altogether, when I
    context switch back to my original app, the _main window_ gets
    the focus (even though the dialog is still there & even though
    I can't interact with the main window).

    Sounds like either a window manager bug (switching away to another app
    and back are not Tk's responsibility). The window manager should be remembering the dialog was present and had focus at the switch away,
    and returning the focus to the dialog when switching back.

    As I wrote earlier, that only works if you do "wm transient" on the
    dialog. The standard dialogs for fileselection e.g. provide a "-parent"
    option do to that. For self-written dialogs that are just ordinary
    toplevels, you need to tell the window manager that they are a dialog.

    Christian
    --- Synchronet 3.21a-Linux NewsLink 1.2