Skip to content

Commit

Permalink
Fix for nib2cib's separator menu items not showing up.
Browse files Browse the repository at this point in the history
Reviewed by me.
  • Loading branch information
Francisco Ryan Tolmasky I committed May 31, 2009
1 parent 0fff3ba commit cc24cd9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
41 changes: 17 additions & 24 deletions AppKit/CPMenuItem.j
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
*/
@implementation CPMenuItem : CPObject
{
BOOL _isSeparator;

CPString _title;
//CPAttributedString _attributedTitle;

Expand Down Expand Up @@ -89,6 +91,8 @@

if (self)
{
_isSeparator = NO;

_title = aTitle;
_action = anAction;

Expand Down Expand Up @@ -479,15 +483,19 @@ CPOffState
*/
+ (CPMenuItem)separatorItem
{
return [[_CPMenuItemSeparator alloc] init];
var separatorItem = [[self alloc] initWithTitle:@"" action:nil keyEquivalent:nil];

separatorItem._isSeparator = YES;

return separatorItem;
}

/*!
Returns <code>YES</code> if the menu item is a separator.
*/
- (BOOL)isSeparatorItem
{
return NO;
return _isSeparator;
}

// Managing the Owning Menu
Expand Down Expand Up @@ -731,29 +739,9 @@ CPControlKeyMask

@end

/* @ignore */
@implementation _CPMenuItemSeparator : CPMenuItem
{
}

- (id)init
{
self = [super initWithTitle:@"" action:nil keyEquivalent:nil];

if (self)
[self setEnabled:NO];

return self;
}

- (BOOL)isSeparatorItem
{
return YES;
}

@end
var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",

var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
CPMenuItemTitleKey = @"CPMenuItemTitleKey",
CPMenuItemTargetKey = @"CPMenuItemTargetKey",
CPMenuItemActionKey = @"CPMenuItemActionKey",

Expand Down Expand Up @@ -787,6 +775,8 @@ var CPMenuItemTitleKey = @"CPMenuItemTitleKey",

if (self)
{
_isSeparator = [aCoder containsValueForKey:CPMenuItemIsSeparatorKey] && [aCoder decodeBoolForKey:CPMenuItemIsSeparatorKey];

_title = [aCoder decodeObjectForKey:CPMenuItemTitleKey];

// _font;
Expand Down Expand Up @@ -832,6 +822,9 @@ var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
if (_isSeparator)
[aCoder encodeBool:_isSeparator forKey:CPMenuItemIsSeparatorKey];

[aCoder encodeObject:_title forKey:CPMenuItemTitleKey];

[aCoder encodeObject:_target forKey:CPMenuItemTargetKey];
Expand Down
3 changes: 2 additions & 1 deletion Tools/nib2cib/NSMenuItem.j
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

if (self)
{
_isSeparator = [aCoder decodeObjectForKey:@"NSIsSeparator"] || NO;

_title = [aCoder decodeObjectForKey:"NSTitle"];

// _font = [aCoder decodeObjectForKey:"NSTitle"];
Expand Down Expand Up @@ -89,7 +91,6 @@

@end


@implementation NSMenuItemCell : NSButtonCell
{
}
Expand Down

0 comments on commit cc24cd9

Please sign in to comment.