diff --git a/AppKit/CPMenu/CPMenu.j b/AppKit/CPMenu/CPMenu.j index 7d0c55a64..7aeacae50 100644 --- a/AppKit/CPMenu/CPMenu.j +++ b/AppKit/CPMenu/CPMenu.j @@ -64,6 +64,8 @@ var _CPMenuBarVisible = NO, CPString _title; CPString _name; + CPFont _font; + float _minimumWidth; CPMutableArray _items; @@ -687,11 +689,6 @@ var _CPMenuBarVisible = NO, if (aView && !theWindow) throw "In call to popUpMenuPositioningItem:atLocation:inView:callback:, view is not in any window."; - var aFont = nil; - - if (!aFont) - aFont = [CPFont systemFontOfSize:12.0]; - var delegate = [self delegate]; if ([delegate respondsToSelector:@selector(menuWillOpen:)]) @@ -702,14 +699,14 @@ var _CPMenuBarVisible = NO, aLocation = [theWindow convertBaseToGlobal:[aView convertPoint:aLocation toView:nil]]; // Create the window for our menu. - var menuWindow = [_CPMenuWindow menuWindowWithMenu:self font:aFont]; + var menuWindow = [_CPMenuWindow menuWindowWithMenu:self font:[self font]]; [menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle]; if (anItem) // Don't convert this value to global, we care about the distance (delta) from the // the edge of the window, which is equivalent to its origin. - aLocation.y -= [menuWindow rectForItemAtIndex:itemIndex].origin.y; + aLocation.y -= [menuWindow deltaYForItemAtIndex:itemIndex]; // Grab the constraint rect for this view. var constraintRect = [CPMenu _constraintRectForView:aView]; @@ -881,6 +878,16 @@ var _CPMenuBarVisible = NO, _menuWindow = aMenuWindow; } +- (void)setFont:(CPFont)aFont +{ + _font = aFont; +} + +- (CPFont)font +{ + return _font; +} + /*! Initiates the action of the menu item that has a keyboard shortcut equivalent to \c anEvent diff --git a/AppKit/CPMenu/_CPMenuWindow.j b/AppKit/CPMenu/_CPMenuWindow.j index 7fc8a5345..7e2db4327 100644 --- a/AppKit/CPMenu/_CPMenuWindow.j +++ b/AppKit/CPMenu/_CPMenuWindow.j @@ -395,6 +395,11 @@ var STICKY_TIME_INTERVAL = 500, return _CPMenuManagerScrollingStateNone; } +- (float)deltaYForItemAtIndex:(int)anIndex +{ + return TOP_MARGIN + CGRectGetMinY([_menuView rectForItemAtIndex:anIndex]); +} + - (CGPoint)rectForItemAtIndex:(int)anIndex { return [_menuView convertRect:[_menuView rectForItemAtIndex:anIndex] toView:nil]; diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index ff7db9ff1..7100db080 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -645,6 +645,9 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down"); bounds = [self bounds], minimumWidth = CGRectGetWidth(bounds); + // FIXME: setFont: should set the font on the menu. + [menu setFont:[self font]]; + if ([self pullsDown]) { var positionedItem = nil, diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index ff0acbffa..ba77318bb 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -880,6 +880,8 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; // We should pay attention to mouse down and mouse up in conjunction with this. //window.liveResize = YES; + [CPApp._activeMenu cancelTracking]; + var oldSize = [self contentRect].size; [self updateFromNativeContentRect]; diff --git a/Tools/nib2cib/NSMenu.j b/Tools/nib2cib/NSMenu.j index 4249a43e0..62e32f3dc 100644 --- a/Tools/nib2cib/NSMenu.j +++ b/Tools/nib2cib/NSMenu.j @@ -53,8 +53,7 @@ NS_CPMenuNameMap = if (mappedName) _name = mappedName; - _showsStateColumn = YES; - //_showsStateColumn = ![aCoder containsValueForKey:@"NSMenuExcludeMarkColumn"] || ![aCoder decodeBoolForKey:@"NSMenuExcludeMarkColumn"]; + _showsStateColumn = ![aCoder containsValueForKey:@"NSMenuExcludeMarkColumn"] || ![aCoder decodeBoolForKey:@"NSMenuExcludeMarkColumn"]; } return self;