diff --git a/AppKit/CPMenu/CPMenu.j b/AppKit/CPMenu/CPMenu.j index 38d354fd7..3a0c92a66 100644 --- a/AppKit/CPMenu/CPMenu.j +++ b/AppKit/CPMenu/CPMenu.j @@ -253,6 +253,8 @@ var _CPMenuBarVisible = NO, _autoenablesItems = YES; _showsStateColumn = YES; + + [self setMinimumWidth:0]; } return self; @@ -649,6 +651,16 @@ var _CPMenuBarVisible = NO, return _title; } +- (void)setMinimumWidth:(float)aMinimumWidth +{ + _minimumWidth = aMinimumWidth; +} + +- (float)minimumWidth +{ + return _minimumWidth; +} + // - (void)popUpMenuPositioningItem:(CPMenuItem)anItem atLocation:(CGPoint)aLocation inView:(CPView)aView callback:(Function)aCallback { @@ -965,6 +977,8 @@ var CPMenuTitleKey = @"CPMenuTitleKey", [self _setMenuName:[aCoder decodeObjectForKey:CPMenuNameKey]]; _showsStateColumn = ![aCoder containsValueForKey:CPMenuShowsStateColumnKey] || [aCoder decodeBoolForKey:CPMenuShowsStateColumnKey]; + + [self setMinimumWidth:0]; } return self; diff --git a/AppKit/CPMenu/_CPMenuWindow.j b/AppKit/CPMenu/_CPMenuWindow.j index 1e33b2a58..0ccf34073 100644 --- a/AppKit/CPMenu/_CPMenuWindow.j +++ b/AppKit/CPMenu/_CPMenuWindow.j @@ -63,6 +63,7 @@ var STICKY_TIME_INTERVAL = 500, [menuWindow setFont:aFont]; [menuWindow setMenu:aMenu]; + [menuWindow setMinWidth:[aMenu minimumWidth]]; return menuWindow; } @@ -210,8 +211,8 @@ var STICKY_TIME_INTERVAL = 500, - (void)setMinWidth:(float)aWidth { - var size = [self frame].size; - + var size = [self unconstrainedFrame].size; + [self setFrameSize:CGSizeMake(MAX(size.width, aWidth), size.height)]; } @@ -276,6 +277,11 @@ var STICKY_TIME_INTERVAL = 500, [super setFrame:_CGRectMake(aPoint.x, aPoint.y, _CGRectGetWidth(_unconstrainedFrame), _CGRectGetHeight(_unconstrainedFrame))]; } +- (void)setFrameSize:(CGSize)aSize +{ + [super setFrame:_CGRectMake(_CGRectGetMinX(_unconstrainedFrame), _CGRectGetMinY(_unconstrainedFrame), aSize.width, aSize.height)]; +} + - (void)setFrame:(CGRect)aFrame display:(BOOL)shouldDisplay animate:(BOOL)shouldAnimate { // FIXME: There are integral window issues with platform windows. diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index 00cbff004..6819794b9 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -654,6 +654,8 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down"); location = CGPointMake(0.0, 0.0); } + [[self menu] setMinimumWidth:CGRectGetWidth(bounds)]; + [[self menu] popUpMenuPositioningItem:positionedItem atLocation:location