X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Categories%2FNSMenu%2BRepresentedObjectAccessors.h;fp=Categories%2FNSMenu%2BRepresentedObjectAccessors.h;h=ecb28a67834f5ae9441553fd08b5ad1deb0c5ffc;hp=0000000000000000000000000000000000000000;hb=0064c1fbff36795885a9724081af2a17d83c20a3;hpb=56d825ba259066d847a9fc3f9c8c0c0a362a1507 diff --git a/Categories/NSMenu+RepresentedObjectAccessors.h b/Categories/NSMenu+RepresentedObjectAccessors.h new file mode 100644 index 0000000..ecb28a6 --- /dev/null +++ b/Categories/NSMenu+RepresentedObjectAccessors.h @@ -0,0 +1,47 @@ +// +// NSMenu+RepresentedObjectAccessors.h +// Enjoyable +// +// Created by Joe Wreschnig on 3/4/13. +// +// + +#import + +@interface NSMenu (RepresentedObjectAccessors) + // Helpers for using represented objects in menu items. + +- (NSMenuItem *)itemWithRepresentedObject:(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. + +- (void)removeLastItem; + // Removes the last menu item in the receiver, if there is one. + // + // After and if it removes the menu item, this method posts an + // NSMenuDidRemoveItemNotification. + +@end + +@interface NSPopUpButton (RepresentedObjectAccessors) + +- (NSMenuItem *)itemWithRepresentedObject:(id)object; + // Returns the first item in the receiver's menu that has a given + // represented object. + +- (void)selectItemWithRepresentedObject:(id)object; + // Selects the first item in the receiver's menu that has a give + // represented object. + +@end