• macOS: No WM_DELETE_WINDOW protocol when using "Quit app"?

    From Torsten@Torsten@example.com to comp.lang.tcl on Sat Feb 22 17:52:39 2025
    From Newsgroup: comp.lang.tcl

    The close icon triggers a WM_DELETE_WINDOW protocol, but not the menu entry "Quit app".
    I use this to register my own exit handler for my app.
    How can I call my own exit handler when the user closes the app via "Quit app"?

    Torsten

    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From nab@user2230@newsgrouper.org.invalid to comp.lang.tcl on Sat Feb 22 17:15:07 2025
    From Newsgroup: comp.lang.tcl


    Torsten <Torsten@example.com> posted:

    The close icon triggers a WM_DELETE_WINDOW protocol, but not the menu entry "Quit app".
    I use this to register my own exit handler for my app.
    How can I call my own exit handler when the user closes the app via "Quit app"?

    Torsten


    Hi,
    in my app I do like that:
    #ifndef HAVE_COCOA
    Tcl_EvalEx(x->interp, "wm protocol . WM_DELETE_WINDOW {exit}", -1, TCL_EVAL_DIRECT);
    #else
    Tcl_EvalEx(x->interp, "wm protocol . WM_DELETE_WINDOW {::tk::mac::Quit}", -1, TCL_EVAL_DIRECT);
    #endif

    and I have an exit proc:
    proc exit {} {
    #do what you want
    }

    ++
    Nicolas
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Robert Heller@heller@deepsoft.com to comp.lang.tcl on Sat Feb 22 19:02:24 2025
    From Newsgroup: comp.lang.tcl

    MacOSX (Finder?) adds an "extra" menu, the Apple Menu (I am assuming that is what you are talking about). Read the section titled "SPECIAL MENUS IN MENUBARS" in the man page for menu (https://www.tcl-lang.org/man/tcl8.3/TkCmd/menu.htm#M19), specificly this paragraph:
    When Tk sees a .menubar.apple menu as the first menu in a menubar on
    the Macintosh, that menu's contents make up the first items of the Ap-
    plication menu whenever the window containing the menubar is in front.
    After all of the Tk-defined items, the menu will have a separator, fol-
    lowed by all standard Application menu items. Such a .apple menu must
    be present in a menu when that menu is first configured as a toplevel's
    menubar, otherwise a default application menu (hidden from Tk) will be
    inserted into the menubar at that time and subsequent addition of a
    .apple menu will no longer result in it becoming the Application menu. Note that there also a "System" menu available on MS-Windows, that can also be accessed from Tk, This is described in the same section.
    At Sat, 22 Feb 2025 17:52:39 +0100 Torsten <Torsten@example.com> wrote:

    The close icon triggers a WM_DELETE_WINDOW protocol, but not the menu entry "Quit app".
    I use this to register my own exit handler for my app.
    How can I call my own exit handler when the user closes the app via "Quit app"?

    Torsten



    --
    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
    --- Synchronet 3.20c-Linux NewsLink 1.2