From: Alastair D. <ala...@si...> - 2005-01-19 15:39:02
|
To the best of my knowledge, the existing code in tkMacOSXHLEvents.c _already_ handles the event triggered by the "Preferences..." = application menu item. The user-defined procedure ::tk::mac::ShowPreferences is = invoked if it exists, or (as Philip kindly points out) the event is ignored if = the procedure does not exist. =20 Incidentally, it would also be convenient (in my case at least) to = invoke an application-specific handler for the "Quit" menu item. I have posted a patch on SourceForge [1] which looks for the user-defined procedure ::tk::mac::Quit. The existing behaviour (evaluating an "exit" script) = is retained if the procedure does not exist. For users porting applications from Windows or *nix systems which use a "File" menu with an "Exit" command, this provides a MacOS X equivalent. Many thanks and kind regards, Alastair Davies [1] http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1105284&grou= p_id=3D12 997&atid=3D362997 -----Original Message----- From: Philip Aker Sent: Wednesday, January 19, 2005 1:31 PM Subject: Re: [MACTCL] Preferences dialog and other apple event handlers On Wednesday, Jan 19, 2005, at 03:17 America/Vancouver, Alastair Davies=20 wrote: > One needs explicitly to enable the "Preferences..." menu item using=20 > the command [1]: > EnableMenuCommand(NULL, kHICommandPreferences); > This call can be made in TkMacOSXInitMenus() for example (in the file=20 > tkMacOSXMenus.c). If the Tcl procedure ::tk::mac::ShowPreferences is=20 > not defined, however, having the menu item enabled is not a good=20 > thing, so this is not a general-purpose patch. Ideally, I suppose, a=20 > Tcl variable could be created to provide script access to enable or=20 > disable the menu item. If the menu item is enabled, you might be able to handle it on a case=20 by case basis by installing a tclAE handler for aevt/pref. The Carbon=20 behavior (in 10.2 and newer I think) is that if the event is not=20 handled, it then falls thru to an AppleEvent handler. The AppleEvent=20 fails gracefully. In TclOSA 1.0.3 <http://homepage.mac.com/philip_aker/osa/osa.html>,=20 this event falls thru to an alert saying that the app has no prefs if=20 there is no script assigned to the menu item. HTH, Philip Aker http://www.aker.ca |