• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSButtonCell in NSTableView: How can I define button action?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: NSButtonCell in NSTableView: How can I define button action? (From: Michael Becker <email@hidden>)

  • Prev by Date: Sending objects using sockets and NSFileHandles I'm working with some sockets and file handles for the first time, and I want to send an image across a network, would this be an appropriate way to do it (conceptually): 1. Client sends string message "image" to server (using writeData:) 2. Server receives string data "image", and so sends image as data (using writeData:) 3. Client now receives image data and converts it to an NSImage. Is this the appropriate way to send images and other objects? Or is there a more conventional method.
  • Next by Date: Easy(?) Cocoa Question
  • Previous by thread: Re: NSButtonCell in NSTableView: How can I define button action?
  • Next by thread: Detecting login/logout?
  • Index(es):
    • Date
    • Thread