diff options
author | das <das> | 2006-04-11 10:22:57 (GMT) |
---|---|---|
committer | das <das> | 2006-04-11 10:22:57 (GMT) |
commit | 9dcd5d48dcc55fb66fe63e83f0e1f6774dd8349f (patch) | |
tree | 57c75211251f73d68ae7066d463fa3e068c204f2 /macosx | |
parent | f5a84a3ca38863707636ae0d1d0cd1df40142ad2 (diff) | |
download | tk-9dcd5d48dcc55fb66fe63e83f0e1f6774dd8349f.zip tk-9dcd5d48dcc55fb66fe63e83f0e1f6774dd8349f.tar.gz tk-9dcd5d48dcc55fb66fe63e83f0e1f6774dd8349f.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')
-rw-r--r-- | macosx/tkMacOSXCarbonEvents.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXEvent.c | 52 |
2 files changed, 40 insertions, 16 deletions
diff --git a/macosx/tkMacOSXCarbonEvents.c b/macosx/tkMacOSXCarbonEvents.c index 81dc0a3..f6aa695 100644 --- a/macosx/tkMacOSXCarbonEvents.c +++ b/macosx/tkMacOSXCarbonEvents.c @@ -60,7 +60,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.3.2.11 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.3.2.12 2006/04/11 10:22:57 das Exp $ */ #include "tkMacOSXInt.h" @@ -192,6 +192,7 @@ TkMacOSXInitCarbonEvents ( {kEventClassMenu, kEventMenuBeginTracking}, {kEventClassMenu, kEventMenuEndTracking}, {kEventClassCommand, kEventCommandProcess}, + {kEventClassCommand, kEventCommandUpdateStatus}, {kEventClassMouse, kEventMouseWheelMoved}, {kEventClassWindow, kEventWindowExpanded}, {kEventClassApplication, kEventAppHidden}, @@ -246,6 +247,7 @@ TkMacOSXInitCarbonEvents ( TraceEventByName("kEventMenuBeginTracking"); TraceEventByName("kEventMenuEndTracking"); TraceEventByName("kEventCommandProcess"); + TraceEventByName("kEventCommandUpdateStatus"); TraceEventByName("kEventWindowExpanded"); TraceEventByName("kEventAppHidden"); TraceEventByName("kEventAppShown"); diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 09e7c7b..fb5869e 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.3.2.5 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.6 2006/04/11 10:22:57 das Exp $ */ #include "tkMacOSXInt.h" @@ -180,12 +180,13 @@ TkMacOSXProcessMenuEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) 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; } |