summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXHLEvents.c
diff options
context:
space:
mode:
authorwolfsuit <wolfsuit>2004-03-17 19:01:45 (GMT)
committerwolfsuit <wolfsuit>2004-03-17 19:01:45 (GMT)
commit64a51bdf01b7ffa1a184f1c8e32a4ccd00443c93 (patch)
tree48e9c91a3d0fb614426b0d0a68c276fe0f45243f /macosx/tkMacOSXHLEvents.c
parent16bfdf9ebd970a07cec78144b103dcbc9542d246 (diff)
downloadtk-64a51bdf01b7ffa1a184f1c8e32a4ccd00443c93.zip
tk-64a51bdf01b7ffa1a184f1c8e32a4ccd00443c93.tar.gz
tk-64a51bdf01b7ffa1a184f1c8e32a4ccd00443c93.tar.bz2
Get the "Command-H" -> hide binding working. Also remove the spurious
Quit menu item from the File command.
Diffstat (limited to 'macosx/tkMacOSXHLEvents.c')
-rw-r--r--macosx/tkMacOSXHLEvents.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c
index 47907fd..e986eab 100644
--- a/macosx/tkMacOSXHLEvents.c
+++ b/macosx/tkMacOSXHLEvents.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.5.2.2 2004/02/16 00:42:34 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.5.2.3 2004/03/17 19:01:46 wolfsuit Exp $
*/
#include "tkMacOSXPort.h"
@@ -45,7 +45,58 @@ static OSErr PrefsHandler (const AppleEvent * event, AppleEvent * reply, long ha
static int MissedAnyParameters _ANSI_ARGS_((const AppleEvent *theEvent));
static int ReallyKillMe _ANSI_ARGS_((Tcl_Event *eventPtr, int flags));
static OSErr FSRefToDString _ANSI_ARGS_((const FSRef *fsref, Tcl_DString *ds));
-
+
+OSStatus ApplicationCarbonEventsHandler (EventHandlerCallRef inHandlerCallRef,
+ EventRef inEvent,
+ void *inUserData);
+OSStatus ApplicationCarbonEventsHandler (EventHandlerCallRef inHandlerCallRef,
+ EventRef inEvent,
+ void *inUserData)
+{
+ Tcl_CmdInfo dummy;
+ Tcl_Interp *interp = (Tcl_Interp *) inUserData;
+
+ /*
+ * This is a bit of a hack. We get "show" events both when we come back
+ * from being hidden, and whenever we are activated. I only want to run the
+ * "show" proc when we have been hidden already, not as a substitute for
+ * <Activate>. So I use this toggle...
+ */
+
+ static int toggleHide = 0;
+
+ switch(GetEventKind (inEvent))
+ {
+ case kEventAppHidden:
+ /*
+ * Don't bother if we don't have an interp or
+ * the show preferences procedure doesn't exist.
+ */
+
+ if ((interp == NULL) ||
+ (Tcl_GetCommandInfo(interp,
+ "::tk::mac::OnHide", &dummy)) == 0) {
+ return eventNotHandledErr;
+ }
+ Tcl_GlobalEval(interp, "::tk::mac::OnHide");
+ toggleHide = 1;
+ break;
+ case kEventAppShown:
+ if (toggleHide == 1) {
+ toggleHide = 0;
+ if ((interp == NULL) ||
+ (Tcl_GetCommandInfo(interp,
+ "::tk::mac::OnShow", &dummy)) == 0) {
+ return eventNotHandledErr;
+ }
+ Tcl_GlobalEval(interp, "::tk::mac::OnShow");
+ }
+ break;
+ default:
+ break;
+ }
+ return eventNotHandledErr;
+}
/*
*----------------------------------------------------------------------
*
@@ -71,7 +122,11 @@ TkMacOSXInitAppleEvents(
AEEventHandlerUPP OappHandlerUPP, RappHandlerUPP, OdocHandlerUPP,
PrintHandlerUPP, QuitHandlerUPP, ScriptHandlerUPP,
PrefsHandlerUPP;
-
+ const EventTypeSpec inAppEventTypes[] = {
+ {kEventClassApplication, kEventAppHidden},
+ {kEventClassApplication, kEventAppShown}};
+ UInt32 inNumTypes = 2;
+
/*
* Install event handlers for the core apple events.
*/
@@ -104,6 +159,13 @@ TkMacOSXInitAppleEvents(
err = AEInstallEventHandler(kAEMiscStandards, kAEDoScript,
ScriptHandlerUPP, (long) interp, false);
}
+
+ InstallEventHandler(GetApplicationEventTarget(),
+ NewEventHandlerUPP (ApplicationCarbonEventsHandler),
+ inNumTypes,
+ inAppEventTypes,
+ (void *) interp,
+ NULL);
}
/*