Re: Toolbar code in separate Controller?
Re: Toolbar code in separate Controller?
- Subject: Re: Toolbar code in separate Controller?
- From: Graham Cox <email@hidden>
- Date: Tue, 8 Jul 2008 01:52:22 +1000
On 8 Jul 2008, at 12:13 am, John Love wrote:
Initially, my ToolbarController was sub to NSObject as was the case
for
Apple's SimpleToolbar, so I changed the super class of my
ToolbarController
to NSControl.
Huh? This makes no sense whatsoever. Why not just make your toolbar's
delegate/controller the document and save yourself a whole heap o'
hassle? That's what I expect most people do and it's the easiest
solution. After all, the document is the controller that pulls
together all the different bits of UI that your app uses per document,
such as toolbars, windows, etc. It's the logical place. Sometimes
making a separate controller makes sense (like for a dialog box),
sometimes making some existing object do that job makes sense -
typically a document subclass does end up acting as a bit of a jack of
all trades in terms of handling various odd bits of different
functionality (but all related to the document, naturally).
If you really want to do it the hard way, you could maybe subclass
NSResponder (but definitely NOT NSControl). Even so, no responder is
put automatically into the responder chain unless it's a view (or
view's "owner") that the user explicitly makes key in some way.
However, your document is in the responder chain by design - another
good reason to use it to handle your toolbar. However, making a
controller a view subclass just to obtain the ability to make it key
is simply wrong and will never work.
I read somewhere that NSView calls [self
setRefusesFirstResponder:FALSE]
Only NSControl and NSCell implement this method, as typing it into the
documentation window's search box will show in a second. So you're
barking up the wrong tree here.
hth,
Graham
_______________________________________________
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