Re: Instance method from IB
Re: Instance method from IB
- Subject: Re: Instance method from IB
- From: Joar Wingfors <email@hidden>
- Date: Wed, 23 Dec 2009 08:35:22 -0800
On 23 dec 2009, at 08.15, Wade Williams wrote:
> 1) Subclass the NSButton and have it call selectTabViewItemAtIndex when pressed
In Cocoa you wouldn't subclass standard controls to implement specific action handling like this. It's not the Cocoa way.
I also curious as to why you would even suggest that solution, given that you're asking for a way to do this all in IB. Writing a full subclass to do this would of course involve more code than using the canonical and straight forward solution: action methods. If you're OK with adding a whole new class, why are you not OK with adding a simple action method?
> 2) Subclass the NSButton and have it respond to indexOfSelectedItem as if it were a segmented controller. Then hook the button to takeSelectedTabViewItemFromSender. While this will work, it seems awfully hackish. Having a single button respond to a method clearly intended for a group of items seems wrong.
Indeed. The "indexOfSelectedItem" is intended to facilitate hooking up to a list control (pop-up button, combo box, form, etc.).
> Anything else? What am I missing? It seems like it should be simple in IB alone to say "when this button is pressed, show this tab" but if there's a way, it's escaping me.
If you only have two tabs (sounds like you might from the original description) you can hook your buttons up to the "-selectNext/PreviousTabViewItem:" action methods on the tab view. This might work for you even if you have more than two tabs, depending on what kind of user experience you're looking for.
j o a r
_______________________________________________
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