diff options
author | das <das> | 2006-04-11 10:22:34 (GMT) |
---|---|---|
committer | das <das> | 2006-04-11 10:22:34 (GMT) |
commit | 0b2e5414581ab039ffccbce58cff46fa8946291d (patch) | |
tree | 8145ed7223f95c40cc285fc9db7a352f43a84dda /macosx/tkMacOSXEvent.c | |
parent | 93e85c8f5894a94877c2a496e6bf0dbc80d721db (diff) | |
download | tk-0b2e5414581ab039ffccbce58cff46fa8946291d.zip tk-0b2e5414581ab039ffccbce58cff46fa8946291d.tar.gz tk-0b2e5414581ab039ffccbce58cff46fa8946291d.tar.bz2 |
* macosx/tkMacOSXCarbonEvents.c: handle kEventCommandUpdateStatus
* macosx/tkMacOSXEvent.c: carbon event to dynamically enable
the 'Preferences' app menu item when proc [::tk::mac::ShowPreferences]
is defined. [Bug 700316]
Diffstat (limited to 'macosx/tkMacOSXEvent.c')
-rw-r--r-- | macosx/tkMacOSXEvent.c | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index ba749a6..5f479b0 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.9 2006/03/24 14:58:01 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.10 2006/04/11 10:22:34 das Exp $ */ #include "tkMacOSXInt.h" @@ -180,12 +180,13 @@ TkMacOSXProcessMenuEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) MODULE_SCOPE int TkMacOSXProcessCommandEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) { - HICommand command; - int menuContext; + HICommand command; + int menuContext; OSStatus status; switch (eventPtr->eKind) { case kEventCommandProcess: + case kEventCommandUpdateStatus: break; default: return 0; @@ -197,18 +198,39 @@ TkMacOSXProcessCommandEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) sizeof(command), NULL, &command); if (status == noErr && (command.attributes & kHICommandFromMenu)) { - status = GetEventParameter(eventPtr->eventRef, - kEventParamMenuContext, - typeUInt32, NULL, - sizeof(menuContext), NULL, - &menuContext); - if (status == noErr && (menuContext & kMenuContextMenuBar) && - (menuContext & kMenuContextMenuBarTracking)) { - TkMacOSXHandleMenuSelect(GetMenuID(command.menu.menuRef), - command.menu.menuItemIndex, - GetCurrentEventKeyModifiers() & optionKey); - return 1; - } + if (eventPtr->eKind == kEventCommandProcess) { + status = GetEventParameter(eventPtr->eventRef, + kEventParamMenuContext, + typeUInt32, NULL, + sizeof(menuContext), NULL, + &menuContext); + if (status == noErr && (menuContext & kMenuContextMenuBar) && + (menuContext & kMenuContextMenuBarTracking)) { + TkMacOSXHandleMenuSelect(GetMenuID(command.menu.menuRef), + command.menu.menuItemIndex, + GetCurrentEventKeyModifiers() & optionKey); + return 1; + } + } else { + Tcl_CmdInfo dummy; + if (command.commandID == kHICommandPreferences && eventPtr->interp) { + if (Tcl_GetCommandInfo(eventPtr->interp, + "::tk::mac::ShowPreferences", &dummy)) { + if (!IsMenuItemEnabled(command.menu.menuRef, + command.menu.menuItemIndex)) { + EnableMenuItem(command.menu.menuRef, + command.menu.menuItemIndex); + } + } else { + if (IsMenuItemEnabled(command.menu.menuRef, + command.menu.menuItemIndex)) { + DisableMenuItem(command.menu.menuRef, + command.menu.menuItemIndex); + } + } + return 1; + } + } } return 0; } |