Re: Linking a menu item between two different classes
Re: Linking a menu item between two different classes
- Subject: Re: Linking a menu item between two different classes
- From: Nick Zitzmann <email@hidden>
- Date: Fri, 23 May 2003 19:42:51 -0700
On Friday, May 23, 2003, at 11:44 AM, Marc Weil wrote:
The project I am working on is an InputManager for another, third-party
application to which I only have the class-dump, no actual code. No
biggie.
So, I have my principal class and I have another class that is a
subclass of
a class in the third-party program, which is a subclass of NSDocument.
So, I
have my +load method in the principal class of my InputManager just
like I
am supposed to, and this function calls my other functions that insert
menu
items, etc. in the main app. Here is where the problem comes in: I am
inserting a new menu item under the File menu (programmatically of
course)
which needs to call saveDocument: in the responder chain so my
subclass of
the applications's subclass of NSDocument can have it's
-dataRepresentationWithType method called. How in the world do I
insert the
menu item from my principal class (which btw is a subclass of
NSObject), and
yet have the target and action of that menu item reside in the
subclass of
the subclass of NSDocument?? This has got me really stuck!
Assuming that the document subclass' subclass is associated with the
main window, what about doing something like this:
1. Implement an -addItem: method in the subclass' subclass that takes
an NSMenuItem and adds it to the appropriate NSMenu.
2. Then, from the NSObject subclass, call this:
[[[NSDocumentController sharedDocumentController] currentDocument]
performSelectorOnMainThread:@selector(addItem:) withObject:item
waitUntilDone:NO];
Only thing is I'm not sure if -currentDocument works with subclasses of
subclasses of NSDocument classes. It definitely works with "regular"
NSDocument subclasses, though. Anyway, that's the first approach I'd
take to solving the problem...
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://dreamless.home.attbi.com/
"Great spirits have always encountered violent opposition from mediocre
minds." - Albert Einstein
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.