Re: NSButtonCell in NSTableView: How can I define button action?
Re: NSButtonCell in NSTableView: How can I define button action?
- Subject: Re: NSButtonCell in NSTableView: How can I define button action?
- From: Henry McGilton <email@hidden>
- Date: Fri, 31 Oct 2003 14:43:16 -0800
On Friday, October 31, 2003, at 11:53 AM, Michael Becker wrote:
In your controller code where you programmatically add the buttons,
you would do something like:
[yourNewButtonInstance setTarget: self]; //
or whomever is supposed to do the job
[yourNewButtonInstance setAction:
(SEL)@selector(jumpThroughHoops:)];
[yourNewButtonInstance setToolTip: @"Cycle Position of Origin"];
// optional
where jumpThroughHoops is your action method. You would define
jumpThroughHoops like this:
- (void) jumpThroughHoops:(id)sender
{
// here is your code to jump through hoops
}
Thanks! That was very helpful. Just one other little question and my
problem is solved: I would like to use the row of the clicked button
in my action method. How do I (syntactically) pass this argument to
the action method?
You can not, at least not all tat easily.
This is my code (snippets):
// right now the variable rowIndex contains the row
[ myButtonCell setAction:(SEL)@selector(deleteObject:)];
. . .
- (void)deleteObject:(id)sender
{
// Here I would like to have the row-index
}
Sorry for asking these questions, but a quick answer will solve all my
problems (I hope) :-)
Thank you!
When you are instantiating a new button, you could use the button's
setTag: method to set the tag to be the row index. Set the tag in
the individual instance, not in the prototype.
Then, in your deleteObject method, you ask the sender for
its tag:
- (void)deleteObject:(id)sender
{
int rowindex = [sender tag];
}
Best Wishes,
........ Henry
===============================+============================
Henry McGilton, Boulevardier | Trilithon Software
Objective-C/Java Composer | Seroia Research
-------------------------------+----------------------------
mailto:email@hidden |
http://www.trilithon.com
|
===============================+============================
_______________________________________________
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.