summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authordas <das>2006-04-11 10:22:57 (GMT)
committerdas <das>2006-04-11 10:22:57 (GMT)
commite709cc3de5af4b8b7e0668f52926f9d57a9049f7 (patch)
tree57c75211251f73d68ae7066d463fa3e068c204f2 /macosx
parentb8b0fe0cff4a16e8c6aad2e00c270298d512d48c (diff)
downloadtk-e709cc3de5af4b8b7e0668f52926f9d57a9049f7.zip
tk-e709cc3de5af4b8b7e0668f52926f9d57a9049f7.tar.gz
tk-e709cc3de5af4b8b7e0668f52926f9d57a9049f7.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.c4
-rw-r--r--macosx/tkMacOSXEvent.c52
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;
}