diff options
-rw-r--r-- | generic/tkMenu.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXMenu.c | 75 |
2 files changed, 44 insertions, 35 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 1cd7a16..1d7c38d 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -1492,6 +1492,7 @@ MenuWorldChanged( for (i = 0; i < menuPtr->numEntries; i++) { TkMenuConfigureEntryDrawOptions(menuPtr->entries[i], menuPtr->entries[i]->index); + fprintf(stderr, "MenuWorldChanged: calling TkpConfigureMenuEntry %d\n", i); TkpConfigureMenuEntry(menuPtr->entries[i]); } TkEventuallyRecomputeMenu(menuPtr); @@ -1873,6 +1874,7 @@ PostProcessEntry( } } + fprintf(stderr, "PostProcessEntry: calling TkpConfigureMenuEntry\n"); if (TkpConfigureMenuEntry(mePtr) != TCL_OK) { return TCL_ERROR; } @@ -2534,6 +2536,7 @@ MenuVarProc( Tcl_TraceVar2(interp, name, NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuVarProc, clientData); + fprintf(stderr, "MenuVarProc: Calling TkpConfigureMenuEntry\n"); TkpConfigureMenuEntry(mePtr); TkEventuallyRedrawMenu(menuPtr, NULL); return NULL; @@ -2563,6 +2566,7 @@ MenuVarProc( } else { return NULL; } + fprintf(stderr, "MenuVarProc: Calling TkpConfigureMenuEntry (2)\n"); TkpConfigureMenuEntry(mePtr); TkEventuallyRedrawMenu(menuPtr, mePtr); return NULL; diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index ee05eb5..e42ae3e 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -409,7 +409,7 @@ TKBackgroundLoop *backgroundLoop = nil; (void)menu; if (_tkMenu) { - //RecursivelyClearActiveMenu(_tkMenu); + // RecursivelyClearActiveMenu(_tkMenu); GenerateMenuSelectEvent((TKMenu *)[self supermenu], [self itemInSupermenu]); } @@ -472,8 +472,8 @@ TKBackgroundLoop *backgroundLoop = nil; } backgroundLoop = [[TKBackgroundLoop alloc] init]; [backgroundLoop start]; - //TkMacOSXClearMenubarActive(); - //TkMacOSXPreprocessMenu(); + // TkMacOSXClearMenubarActive(); + // TkMacOSXPreprocessMenu(); } - (void) menuEndTracking: (NSNotification *) notification @@ -725,45 +725,49 @@ TkpConfigureMenuEntry( [title substringToIndex:[title length] - 3], 0x2026]; } } - [menuItem setTitle:title]; - fontAttributes = TkMacOSXNSFontAttributesForFont(Tk_GetFontFromObj( - mePtr->menuPtr->tkwin, fontPtr)); - attributes = [fontAttributes mutableCopy]; - if (gc->foreground != defaultFg) { + if ([title length]) { + fontAttributes = TkMacOSXNSFontAttributesForFont(Tk_GetFontFromObj( + mePtr->menuPtr->tkwin, fontPtr)); + attributes = [fontAttributes mutableCopy]; + if (gc->foreground != defaultFg) { - /* - * Apple's default foreground color changes to white when the menuitem is - * selected. If a custom foreground color is used then the color will be - * the same for selected and unselected menu items. - */ + /* + * Apple's default foreground color changes to white when the menuitem is + * selected. If a custom foreground color is used then the color will be + * the same for selected and unselected menu items. + */ - NSColor *fgcolor = TkMacOSXGetNSColor(gc, gc->foreground); - [attributes setObject:fgcolor - forKey:NSForegroundColorAttributeName]; - } - if (gc->background != defaultBg) { + NSColor *fgcolor = TkMacOSXGetNSColor(gc, gc->foreground); + [attributes setObject:fgcolor + forKey:NSForegroundColorAttributeName]; + } + if (gc->background != defaultBg) { - /* - * Setting a background color looks awful. But setting the background should - * not be the same as setting the foreground. As a compromise, if the background - * color is set we draw an underline in that color. - */ - NSColor *bgcolor = TkMacOSXGetNSColor(gc, gc->background); - [attributes setObject:bgcolor - forKey:NSUnderlineColorAttributeName]; - [attributes setObject:[NSNumber numberWithInt:NSUnderlineStyleDouble] - forKey:NSUnderlineStyleAttributeName]; + /* + * Setting a background color looks awful. But setting the background should + * not be the same as setting the foreground. As a compromise, if the background + * color is set we draw an underline in that color. + */ + NSColor *bgcolor = TkMacOSXGetNSColor(gc, gc->background); + [attributes setObject:bgcolor + forKey:NSUnderlineColorAttributeName]; + [attributes setObject:[NSNumber numberWithInt:NSUnderlineStyleDouble] + forKey:NSUnderlineStyleAttributeName]; + } + attributedTitle = [[NSAttributedString alloc] + initWithString:title + attributes:attributes]; + [menuItem setAttributedTitle:attributedTitle]; } - attributedTitle = [[[NSAttributedString alloc] - initWithString:title attributes:attributes] autorelease]; - [menuItem setAttributedTitle:attributedTitle]; - [menuItem setEnabled:!(mePtr->state == ENTRY_DISABLED)]; + fprintf(stderr, "Item %s has tk state %x apple enabled %d\n", + title.UTF8String, mePtr->state, [menuItem isEnabled]); + [menuItem setEnabled:(mePtr->state & ENTRY_DISABLED) == 0 || [title length] == 0]; [menuItem setState:((mePtr->type == CHECK_BUTTON_ENTRY || - mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn && - (mePtr->entryFlags & ENTRY_SELECTED) ? NSOnState : NSOffState)]; + mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn && + (mePtr->entryFlags & ENTRY_SELECTED) ? NSOnState : NSOffState)]; if (mePtr->type != CASCADE_ENTRY && mePtr->accelPtr && mePtr->accelLength) { keyEquivalent = ParseAccelerator(Tcl_GetString(mePtr->accelPtr), - &modifierMask); + &modifierMask); } [menuItem setKeyEquivalent:keyEquivalent]; [menuItem setKeyEquivalentModifierMask:modifierMask]; @@ -776,6 +780,7 @@ TkpConfigureMenuEntry( CheckForSpecialMenu(menuRefPtr->menuPtr); submenu = (TKMenu *) menuRefPtr->menuPtr->platformData; if ([submenu supermenu] && [menuItem submenu] != submenu) { + /* * This happens during a clone, where the parent menu is * cloned before its children, so just ignore this temprary |