Tk Source Code

View Ticket
Login
Ticket UUID: c9ebacceb4bca69f66215731e8aa68f4adcd2ed8
Title: Aqua : about ::tk::mac::standardAboutPanel
Type: Bug Version:
Submitter: nab Created on: 2020-10-19 14:50:15
Subsystem: 66. Aqua Window Operations Assigned To: marc_culler
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2020-11-06 19:17:05
Resolution: Fixed Closed By: nab
    Closed on: 2020-11-06 19:17:05
Description:
Hi Marc,
the manual says:
Brings the standard Cocoa about panel to the front, with all its information filled in from your application bundle files (standard about panel with no options specified).

If I try to use ::tk::mac::standardAboutPanel command, the window pop-up with Tcl&Tk info.

in my app I've an Info.plist file filled with icon reference, bundle name, etc...
Would it be possible to use my Info.plist info?
Or if it's not possible, can't we use AppMain.tcl file to fill the standardAboutPanel?

best regards,
nicolas
User Comments: nab added on 2020-11-06 19:17:05:
thank you for the mac_style merge.

++

marc_culler (claiming to be Marc Culler) added on 2020-11-06 18:05:59:
I am reclassifying this as a bug, since the behavior contradicted the manual.

I have merged the mac_about branch and will close this now.

marc_culler (claiming to be Marc Culler) added on 2020-11-06 16:06:49:
@nab: I don't see any way to return focus to a different window when the
standardAboutPanel is closed.  Tk does not receive any events from that
panel.  Its window does not even appear in the Window menu.  There seems
to be no way for Tk to even tell if the panel is open or not.

Again, if you want something better you have to write it yourself.  And
now we know how to do it: just define a proc named tkAboutDialog.  If you
define that proc, it will be called when the "About My App" menu is selected.
You can do anything you want in that proc.

marc_culler (claiming to be Marc Culler) added on 2020-11-06 15:54:27:
@Kevin: not exactly.  In tkMacOSXMenus.c there is an implementation of
[TKApplication standardAboutPanelOrderFront:] which overrides the built-in
method of NSApplication.  The custom method checks whether there is a
tkAboutDialog command defined in the main interpreter.  If so it runs that
command rather than calling super. (Well, in the mac_about branch it now
calls super, but in the core-8-6-branch it calls a function that creates a
special AlertPanel.)

What this means is that it is easy to override the standardAboutPanel in your
Tcl code, by simply defining a tkAboutDialog proc.  That is a good feature
and should be documented, for sure. I am not sure where the documentation
could go other than in the man page for tk::mac::standardAboutPanel.  But
tkAboutDialog is not a Tk command, it is just a hook for adding your own
"about" dialog.

Also, that hook only exists for macOS.  There is no reference to tkAboutDialog
in the win directory or in the library.

kevin_walzer added on 2020-11-06 14:49:18:
@Marc - It is in tkMacOSXMenus.c and is wired up to the "About" menu entry.

nab added on 2020-11-06 14:44:27:
ok,
when closing the standardAboutPanel is it possible to give the focus back to .

++

marc_culler (claiming to be Marc Culler) added on 2020-11-06 14:24:25:
@Nicolas: No, you cannot add any x padding.  I tried. The html renderer
ignores all of the css padding and margin commands.  Maybe you could control
the margins with RTF, but I doubt it.

Also, I don't think there is any way to make the panel respond to command-W
or, actually, any event.  It is like the fontchooser and the colorpicker.
It is completely managed by the OS.  There is an NSApplication method
standardAboutPanelOrderFront, but there is no method to order it out.
The only way that Apple provides for closing it is to press the red button.
If you want any features like that you need to write your own about dialog.
The standardAboutPanel is a very limited feature, meant as a placeholder to
make sure that every macOS app does something when you select that menu item.

@Kevin: I searched for tkAboutDialog in the source code and all I found was
a Tcl proc with that name in the widget demo.  So, from what I can see, that
undocumented command does not exist.

nab added on 2020-11-06 11:46:16:
and also, it would be nice if Cmd+W close the about panel

++

nab added on 2020-11-06 11:42:52:
Hi Marc,
I've test the mac_about branch and it's very very clean, thanks.
Just a note regarding the credits section, maybe you could add little x padding to give it some air...

it would be very nice if you could merge it to mac_styles

best regards,
nicolas

kevin_walzer added on 2020-11-05 21:31:40:
I've tested this branch and it works fine, but I think it might make more sense to remove the standardAboutPanel command from the man page altogether and replaced it with tkAboutDialog, which is an undocumented (to my knowledge) command that plugs into the "About Tcl&Tk" menu command on Mac and Windows and displays whatever dialog you care to put there. I don't see any value in using the standardAboutPanel command - Daniel Steffen put it in there as a late addition to the initial Cocoa port of Tk and it has never been used much, to my knowledge.

marc_culler (claiming to be Marc Culler) added on 2020-11-05 19:47:05:
I have looked into this a bit.  This is what I found:

We are no longer using the Apple standardAboutPanel.  This is the reason why
the manual page is not correct anymore.

There was a reason to stop using it.  The reason was that when Mojave was
released the standardAboutPanel was not unreadable in Dark Mode. But that
reason is not applicable any more, now that we have semantic colors. In
place of the standardAboutPanel, Tk currently uses a panel which is based on
the NSAlert class.

The Apple standardAboutPanel has an icon at the top. Below that is the app
name; below that is the version number; below that is the copyright statement;
and below that is a scrolling window containing the "credits".  The app name,
version number and copyright statement are taken from the Info.plist by default.
The credits are taken from a Credits.html file if one is found in the app
Resources directory.  The custom "About" panel does not use that information
currently.  However it could use it.

The Apple standardAboutPanel is small, not resizable and not configurable
beyond these four items.  It is not used that heavily since people want fancier
"About" windows.  Of course, these can be written in Tcl.

I have created a branch mac_about which removes the custom panel and replaces
it with the standardAboutPanel.

I think we have two choices here.  We could either modify the custom about panel
so that it looks up the same information as the standardAboutPanel or we could
revert to using the standardAboutPanel.  In either case the manual page needs
to be more specific about where the information comes from.

By the way, Apple allows the Credits.html to be replaced by Credits.rtf.  I
can't imagine why anyone would want to do that, however.  Also, the html
rendering that it uses is very primitive.  It ignores most CSS but it does
allow you to set the font-size and font-family.

nab added on 2020-10-21 08:33:13:
Hi Marc,
thanks for the info and ok I'll try (in a couple of weeks though...)

++

marc_culler (claiming to be Marc Culler) added on 2020-10-21 02:02:04:
This page, from 18 years ago, claims to explain where Apple looks for information to put in the About panel

http://cocoadevcentral.com/articles/000071.php

It would be interesting to test which, if any, of those still work.

Since the Tk code sets the "credits" option, changing that will probably
require changing the current code.  But the other things might work.
The other possibility is that Apple stopped looking in those places.
I can't find anything in the Apple documentation about that.  (Surprise!)

marc_culler (claiming to be Marc Culler) added on 2020-10-20 22:12:29:
The about panel was a last minute punt to get something that at least
worked when Tk was being released in the Mojave desert.  No one ever
got back to it.  The "credits" option is a hardwired constant string
in tkMacOSXDialog.c.  It should be somehow extracted from the
environment, with the current string being the default.  That should
not be difficult.

What a great project for getting started on contributing to Tk!  All
we need is a patch.  Hint, hint, hint, ...

I am not sure why the manual says that the information comes from the
Info.plist file.  There is no sign of that in the code now.  Maybe the
old about dialog which stopped working with Mojave actually did do
that somehow.  It might be enlightening to look an old version of the
file.

nab added on 2020-10-20 14:13:40:
Hi Brad,
yes, this is exactly what I do but as it seems to be preferable to use provided functions on Mac (as ::tk::mac::Quit, etc...) I would like to use the standardAboutPanel

best regards,
Nicolas

bll added on 2020-10-19 16:25:00:
I was curious.  ::tk::mac::standardAboutPanel doesn't display anything
from my Info.plist either.

You can replace the menu and display what you want.
(I don't use the Mac OS menus, but I do put a few things in place).

Mac OS still adds other things to the menu.

menu $tww.menuglobal
menu $tww.menuglobal.apple -tearoff 0
$tww.menuglobal.apple add command \
  -label {About BallroomDJ} \
  -command  ::ballroomdj::aboutDisplay
$tww.menuglobal add cascade \
  -label BallroomDJ \
  -menu $tww.menuglobal.apple
$w configure -menu $tww.menuglobal