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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to