// Helpers for using represented objects in menu items.
- (NSMenuItem *)itemWithRepresentedObject:(id)object;
+- (NSMenuItem *)itemWithIdenticalRepresentedObject:(id)object;
// Returns the first menu item in the receiver that has a given
// represented object.
-- (void)removeItemWithRepresentedObject:(id)object;
- // Removes the first menu item representing the given object in the
- // receiver.
- //
- // After it removes the menu item, this method posts an
- // NSMenuDidRemoveItemNotification.
-
- (NSMenuItem *)lastItem;
// Return the last menu item in the receiver, or nil if the menu
// has no items.
@interface NSPopUpButton (RepresentedObjectAccessors)
- (NSMenuItem *)itemWithRepresentedObject:(id)object;
+- (NSMenuItem *)itemWithIdenticalRepresentedObject:(id)object;
// Returns the first item in the receiver's menu that has a given
// represented object.
- (void)selectItemWithRepresentedObject:(id)object;
+- (void)selectItemWithIdenticalRepresentedObject:(id)object;
// Selects the first item in the receiver's menu that has a give
// represented object.
return nil;
}
-- (void)removeItemWithRepresentedObject:(id)object {
- NSInteger idx = [self indexOfItemWithRepresentedObject:object];
- if (idx != -1)
- [self removeItemAtIndex:idx];
+- (NSMenuItem *)itemWithIdenticalRepresentedObject:(id)object {
+ for (NSMenuItem *item in self.itemArray)
+ if (item.representedObject == object)
+ return item;
+ return nil;
}
- (NSMenuItem *)lastItem {
return [self.menu itemWithRepresentedObject:object];
}
+- (NSMenuItem *)itemWithIdenticalRepresentedObject:(id)object {
+ return [self.menu itemWithIdenticalRepresentedObject:object];
+}
+
- (void)selectItemWithRepresentedObject:(id)object {
[self selectItemAtIndex:[self indexOfItemWithRepresentedObject:object]];
}
+- (void)selectItemWithIdenticalRepresentedObject:(id)object {
+ NSMenuItem *item = [self.menu itemWithIdenticalRepresentedObject:object];
+ [self selectItem:item];
+}
+
@end
keyInput.keyCode = [(NJOutputKeyPress*)output keyCode];
} else if ([output isKindOfClass:NJOutputMapping.class]) {
[radioButtons selectCellAtRow:2 column:0];
- NSMenuItem *item = [mappingPopup itemWithRepresentedObject:[(NJOutputMapping *)output mapping]];
+ NSMenuItem *item = [mappingPopup itemWithIdenticalRepresentedObject:[(NJOutputMapping *)output mapping]];
[mappingPopup selectItem:item];
unknownMapping.hidden = !!item;
unknownMapping.title = [(NJOutputMapping *)output mappingName];
item.representedObject = mapping;
[mappingPopup.menu addItem:item];
}
- [mappingPopup selectItemWithRepresentedObject:current];
+ [mappingPopup selectItemWithIdenticalRepresentedObject:current];
}
- (void)mappingDidChange:(NSNotification *)note {
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>479</string>
+ <string>482</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>NSHumanReadableCopyright</key>