• 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: fresh newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fresh newbie question


  • Subject: Re: fresh newbie question
  • From: Nir Soffer <email@hidden>
  • Date: Fri, 22 Feb 2008 03:13:45 +0200


On Feb 18, 2008, at 16:59, Mei Fang Liau wrote:

I wrote a controller class inherited from NSObject, which contains a outlet
with the main window (NSWindow) as the destination. This outlet is used to
scan the main window's subviews and find all check boxes and store them in
an array. Can I also do the same thing with a controller inherited from
NSView? On the main window there are some check boxes and a custom view. I
would like to change the color of my custom view according to the check
boxes' status. But I find out that I can't likewise just set an Outlet for
this subclass of NSView and scan the content of the main window... can
anyone give me some suggestion? (or what tutorial I should check out...
there are just too many functionalities I am lost :o)

You don't need to scan for checkboxes.

You create a checkbox matrix by adding a checkbox and then resizing it with the Option key pressed. Then you connect the checkbox to some action in your controller, e.g. changeSelection:. Each time the user change the selection, your action is called and can check the state and change the custom view color.

If you have multiple checkboxes groups, you either have an outlet for each, or keep the state in some other way in your controller and update it when the user makes a change.

Your controller can look like this:


@interface MyController : NSObject { IBOutlet NSButton *checkboxMatrix; IBOutlet MyView *colorView; } - (IBAction)changeSelection:(id)sender; @end

@implementation MyController

- (IBAction)changeSelection:(id)sender;
{
	// check sender state and update the view
	[view setColor:[NSColor redColor]];
	[view setNeedsDisplay:YES];
}

@end


Warning: compiles in Mail.app


Best Regards,

Nir Soffer

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >fresh newbie question (From: "Mei Fang Liau" <email@hidden>)

  • Prev by Date: Re: Binding an entity object (not an entity attribute) to a Table View Column
  • Next by Date: Predicate works with array controller but not fetch request
  • Previous by thread: Re: fresh newbie question
  • Next by thread: [ANN] SSCrypto openssl command line compatibility update
  • Index(es):
    • Date
    • Thread