From f8a5f916875e043350430e1020174219656c2b80 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Mon, 30 Nov 2009 21:28:42 -0800 Subject: [PATCH] Fix for nib2cib leaving cells as targets for menu items. Reviewed by me. --- Tools/nib2cib/NSIBObjectData.j | 10 ++++++++++ Tools/nib2cib/NSMenuItem.j | 13 +++++++++++++ Tools/nib2cib/NSPopUpButton.j | 5 +++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Tools/nib2cib/NSIBObjectData.j b/Tools/nib2cib/NSIBObjectData.j index 26d2e5481..1f1fc43c1 100644 --- a/Tools/nib2cib/NSIBObjectData.j +++ b/Tools/nib2cib/NSIBObjectData.j @@ -132,6 +132,16 @@ _objectsValues.push(parent); }); } + + var count = _objectsKeys.length; + + while (count--) + { + var object = _objectsKeys[count]; + + if ([object respondsToSelector:@selector(swapCellsForParents:)]) + [object swapCellsForParents:parentForCellUIDs]; + } } @end diff --git a/Tools/nib2cib/NSMenuItem.j b/Tools/nib2cib/NSMenuItem.j index 9630cf35f..17e611004 100644 --- a/Tools/nib2cib/NSMenuItem.j +++ b/Tools/nib2cib/NSMenuItem.j @@ -74,6 +74,19 @@ return self; } +- (void)swapCellsForParents:(JSObject)parentsForCellUIDs +{ + var target = [self target]; + + if (!target) + return; + + var parent = parentsForCellUIDs[[[self target] UID]]; + + if (parent) + [self setTarget:parent]; +} + @end @implementation NSMenuItem : CPMenuItem diff --git a/Tools/nib2cib/NSPopUpButton.j b/Tools/nib2cib/NSPopUpButton.j index e86956741..04175cd3b 100644 --- a/Tools/nib2cib/NSPopUpButton.j +++ b/Tools/nib2cib/NSPopUpButton.j @@ -24,6 +24,7 @@ @import "NSMenu.j" + @implementation CPPopUpButton (CPCoding) - (id)NS_initWithCoder:(CPCoder)aCoder @@ -32,8 +33,8 @@ { var cell = [aCoder decodeObjectForKey:@"NSCell"]; - _menu = [cell menu]; - + _menu = [cell menu]; + // make sure it's not null/undefined //FIXME push this check to CPPopUpButton? _selectedIndex = [cell selectedIndex] || 0;