mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-09 12:17:13 +00:00
Fix for not being able to add/remove items from main menubar.
[#72 state:resolved] Reviewed by rossco.
This commit is contained in:
+38
-1
@@ -248,7 +248,7 @@ var _CPMenuBarVisible = NO,
|
||||
[_items removeObjectAtIndex:anIndex];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPMenuDidAddItemNotification
|
||||
postNotificationName:CPMenuDidRemoveItemNotification
|
||||
object:self
|
||||
userInfo:[CPDictionary dictionaryWithObject:anIndex forKey:@"CPMenuItemIndex"]];
|
||||
}
|
||||
@@ -1305,6 +1305,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
|
||||
{
|
||||
CPMenu _menu;
|
||||
CPView _highlightView;
|
||||
CPArray _menuItemViews;
|
||||
|
||||
CPMenuItem _trackingMenuItem;
|
||||
|
||||
@@ -1447,6 +1448,8 @@ var _CPMenuBarWindowBackgroundColor = nil,
|
||||
object:_menu];
|
||||
}
|
||||
|
||||
_menuItemViews = [];
|
||||
|
||||
var contentView = [self contentView],
|
||||
items = [_menu itemArray],
|
||||
count = items.length;
|
||||
@@ -1455,6 +1458,8 @@ var _CPMenuBarWindowBackgroundColor = nil,
|
||||
{
|
||||
var item = items[index],
|
||||
menuItemView = [item _menuItemView];
|
||||
|
||||
_menuItemViews.push(menuItemView);
|
||||
|
||||
[menuItemView setShowsStateColumn:NO];
|
||||
[menuItemView setBelongsToMenuBar:YES];
|
||||
@@ -1480,6 +1485,38 @@ var _CPMenuBarWindowBackgroundColor = nil,
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)menuDidAddItem:(CPNotification)aNotification
|
||||
{
|
||||
var index = [[aNotification userInfo] objectForKey:@"CPMenuItemIndex"],
|
||||
menuItem = [_menu itemAtIndex:index],
|
||||
menuItemView = [menuItem _menuItemView];
|
||||
|
||||
[_menuItemViews insertObject:menuItemView atIndex:index];
|
||||
|
||||
[menuItemView setShowsStateColumn:NO];
|
||||
[menuItemView setBelongsToMenuBar:YES];
|
||||
[menuItemView setFont:_CPMenuBarWindowFont];
|
||||
[menuItemView setHidden:[menuItem isHidden]];
|
||||
|
||||
[menuItemView synchronizeWithMenuItem];
|
||||
|
||||
[[self contentView] addSubview:menuItemView];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (void)menuDidRemoveItem:(CPNotification)aNotification
|
||||
{
|
||||
var index = [[aNotification userInfo] objectForKey:@"CPMenuItemIndex"],
|
||||
menuItemView = [_menuItemViews objectAtIndex:index];
|
||||
|
||||
[_menuItemViews removeObjectAtIndex:index];
|
||||
|
||||
[menuItemView removeFromSuperview];
|
||||
|
||||
[self tile];
|
||||
}
|
||||
|
||||
- (CGRect)frameForMenuItem:(CPMenuItem)aMenuItem
|
||||
{
|
||||
var frame = [[aMenuItem _menuItemView] frame];
|
||||
|
||||
Reference in New Issue
Block a user