• 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: Setting a class' action
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting a class' action


  • Subject: Re: Setting a class' action
  • From: Chris Giordano <email@hidden>
  • Date: Thu, 15 Aug 2002 09:28:52 -0400

Andrew,

My first thought on this was that you could look at all of the subviews of the view containing all of your buttons and set them based on the class.

I did a quick little test app and implemented the following action:

- (IBAction)doYourThing:(id)sender
{
NSEnumerator * e = [[[myWindow contentView] subviews] objectEnumerator];
id obj;

while (obj = [e nextObject])
{
NSLog(@"Got subview %@", obj);
if ([obj isKindOfClass:[NSButton class]])
[obj setAction:@selector(justBeep:)];
}
}

myWindow is an outlet to the window in question, and I put a bunch of buttons into the window.

I don't guarantee that the isKindOfClass is the absolutely correct method for you to use -- it worked in my case, but if you have other buttons in your window, they might also get the action set. You'd need to have some way to identify only the buttons that you wanted to use -- by tag, or if they are a subclass and have a unique method that they respond to (like the one you are setting the action to), or something else.

chris

On Wednesday, August 14, 2002, at 08:28 PM, Andrew Merenbach wrote:

I would like every one of about 109 different buttons in a periodic table of the elements to call the same action. Each button uses a custom subclass of NSButton, in a different color. I can assign the actions to all the buttons manually, but since there are several differently-colored periodic tables in my program, this could take hours. Is there a way to set an action of all buttons of a particular class in the class definition file?

Take care,
Andrew Merenbach
_______________________________________________
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.

References: 
 >Setting a class' action (From: Andrew Merenbach <email@hidden>)

  • Prev by Date: Re: cocoa and argv
  • Next by Date: Re: Getting classes from bundles in an array
  • Previous by thread: Re: Setting a class' action
  • Next by thread: Re: Setting a class' action
  • Index(es):
    • Date
    • Thread