Re: Subviews and their contextual menu
Re: Subviews and their contextual menu
- Subject: Re: Subviews and their contextual menu
- From: Tobias Hermann <email@hidden>
- Date: Tue, 3 Jun 2003 12:24:39 +0200
hi!
This is not the way to go...
IMHO it is better to use the first responder chain.
Think of a menu item in your contextual menu, that is named "Do Some
Stuff".
The action method that should be called is named
- (void) doSomeStuff: (id) sender;
Now comes the clue: Do not hard connect the target/action pair, connect
it to the nib files first responder icon.
Therefore, the nibs firstResponder has to know about a method called
doSomeStuff:, so double click on the first Responder Icon, go to the
Actions Tab in the Inspector, add an action method called doSomeStuff:.
Now connect the action of your menu item to the firstResponder's
doSomeStuff: action, not to the window controller's like u first did.
Now every view that should handle such a menu action simply has to
implement a
-(void) doSomeStuff: (id) sender;
method.
Due to that the menu gets opend by the view that gets command/right
clicked, it is above other views in the responder chain.
For views that don't implement doSomeStuff: add a doSomeStuff to your
window Controller (which shoould be the window's delegate), then this
is the last method that gets called if no view in the responder chain
responded to doSomeStuff:.
I hope i explained it well enough... It's not easy to explain in short
words... If you didn't understand everything (due to my strange english
or why ever :-) ), feel free to ask again...
Regards
Tobi
On Tuesday, June 3, 2003, at 11:59 AM, Johan Kool wrote:
Hello all,
I have a scrollview to which documentview I add subviews. I've
subclassed my subview to add tags so I can identify them. Each subview
I connect to a contextual menu using setMenu. I've connected one
menuitem to an action in a windowcontroller. Now if the user uses the
connected contextual menu item, how do I know which subview was used
to show the contextual menu? Sender refers to the contextual menu
itself obviously.
Thanks in advance!
Johan Kool
_______________________________________________
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.
_______________________________________________
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.