Re: first responder stopped working
Re: first responder stopped working
- Subject: Re: first responder stopped working
- From: Sean Murphy <email@hidden>
- Date: Sun, 14 Dec 2008 17:15:49 -0500
On Dec 13, 2008, at 11:50 PM, John Nairn wrote:
My application frequently recreates a window which involves deleting
all the subviews and adding new ones (while keeping the window
open). It used to work, but now when it reloads, it fails to accept
the one view I designate to the be the first view.
After the window is recreated I perform a delayed method and use
if(firstCell!=nil)
{ id aView = [firstCell theView];
if([aView acceptsFirstResponder])
{ [[self window] makeFirstResponder:aView];
}
else
NSLog(@"does not accept to be responder");
}
This used to work, but has recently stopped working. When the window
displays, the view (firstCell is my object and the views are all
NSTextField views) does get selected. If I tab, one of two things
happens:
1. It tabs to the next view making it look like the view is
partially made the first responded, but never selected
2. Other times the window freezes up with this error message
*** NSRunStorage, _NSBlockNumberForIndex(): index (4294967294)
beyond array bounds (30)
which I do not recognize in my code.
Hey John,
I have a couple of suggestions you can try in this situation...
- You can check out -[NSWindow setAutorecalculatesKeyViewLoop:] or
just -[NSWindow recalculateKeyViewLoop] to have AppKit automatically
attempt to connect the loop based on geometric ordering.
- When you fill the window's content view with your new subviews, if
you have the same few collections of views which will always be
loaded, you can create the parent views in Interface Builder, and wire
up the nextKeyViews on entire collection of subviews there, and then
just swap in a ready to go parent view into your window.
- Finally, you can try to debug your current setup. If there is an
array out of bounds messaging being logged, there should be an
exception you can catch. On leopard, add a symbolic breakpoint on
objc_exception_throw, and then examine the stack trace in gdb to find
out more about what is going on.
You can also throw F-Script Anywhere into your program, and examine
the views of your window, checking out what their nextKeyView is set
to, to help debug this further.
Good luck,
Sean.
_______________________________________________
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