Re: becomeFirstResponder override issue
Re: becomeFirstResponder override issue
- Subject: Re: becomeFirstResponder override issue
- From: Chris Anderson <email@hidden>
- Date: Mon, 02 Feb 2009 11:19:19 -0800
Ok, upon further investigation it would seem that the objects are
initializing in an order I don't understand. I verified this by
overriding the mouseDown method and getting the same results. I also
tried invoking awakeFromNib but that too did not work. I tried a
performSelector:withObject:afterDelay within the awakeFromNib and
called a separate method to get the array controller to respond.
awakeFromNib was invoked twice on application start...the first time
the array controller responds successfully. The second time, where
the datepicker control in the nib is actually loaded, it does not
respond.
- (void)awakeFromNib
{
[self performSelector: @selector(prepareOutlets)
withObject: nil
afterDelay: 1.0];
}
-(void)prepareOutlets
{
NSLog(@"array count: %i", [[myArrayController arrangedObjects] count]);
}
Log...
2009-02-02 11:04:05.375 [myapp] array count: 1 (I think this is the
object of the subclass I've created in IB)
2009-02-02 11:04:05.385 [mhapp] array count: 0 (NSDatePicker control
is calling this one..verified)
I must be missing something fundamental but I have no idea what.
Thanks,
C.
On 2-Feb-09, at 8:54 AM, Chris Anderson wrote:
So the fact that I am referencing a controller inside
becomeFirstResponder hasn't raised any alarms with anyone yet so I
could assume that it's ok to do so. If this is the case then I'm
either doing something wrong somewhere or perhaps there is an issue
with subclassing NSDatePicker. I will try subclassing another
control and overridding it's becomeFirstResponder to see what happens.
Thanks,
C.
On 2-Feb-09, at 8:44 AM, Keary Suska wrote:
On Feb 2, 2009, at 8:44 AM, Chris Anderson wrote:
Thanks. And yes the controller has content. In my example below
it returns 0 when inside becomeFirstResponder and returns > 0 when
I activate detectPicker in the same application instance.
I was more interested in whether myArrayController is nil when -
becomeFirstResponder is called. The NSLog below won't tell you
that, so I wasn't sure if you specifically checked for nil.
On 2-Feb-09, at 7:40 AM, Keary Suska wrote:
On Feb 1, 2009, at 10:32 PM, Chris Anderson wrote:
I've created a subclass of NSDatePicker to catch when a date
picker has focus. I have overridden the becomeFirstResponder
method and indeed it detects when it has focus. The code inside
the method does work except for any IBOutlets that I may have
connected. They don't respond to any requests.
I have verified that the IBOutlets are connected by adding a
separate IBAction in the subclass and a simple button to invoke
the action. Inside the IBAction I can call the same IBOutlets
successfully.
I am baffled as to why when the IBOutlets are inside
becomeFirstResponder they don't seem connected. Example below...
-(BOOL)becomeFirstResponder // myArrayController will not respond
{ NSLog(@"DetectDatePicker:firstResponder: %i",
[[myArrayController arrangedObjects] count]);
return YES;
}
-(IBAction)detectPicker:(id)sender // myArrayController
successfully responds
{ NSLog(@"DetectDatePicker:performClick: %i",[[myArrayController
arrangedObjects] count]);
}
Have you checked whether myArrayController is nil, just whether
it has content? Those would likely be two separate issues...
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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
_______________________________________________
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