Setting up the nextKeyView programmatically
-
hi dear group,
as a cocoa newbee I'm stuck with the following problem:
how do I set up the nextKeyView-order of a couple of NSTextFields
programmatically, when each NSTextField is located inside its own
NSClipView?
the background:
I have to use an existing framework that puts each NSTextField inside
an NSClipView (for whatever reason). the fields/views are created
programmatically, so I can't use IB to set up the nextKeyView.
I want to make sure that tabbing between the Fields works as usual.
Searching the web and the archives wasn't sucessful for the last
days, so I hope somebody can help me here...
thanks for any ideas or hints!
regards,
jan -
On Sep 4, 2007, at 4:28 PM, Jan David Frölich wrote:
> [H]ow do I set up the nextKeyView-order of a couple of NSTextFields...
> programmatically, when each NSTextField is located inside its own
> NSClipView?
> I want to make sure that tabbing between the Fields works as usual.
> Searching the web and the archives wasn't sucessful for the last
> days, so I hope somebody can help me here...
You don't say whether you tried the setNextKeyView: method, and what
the result was.
— F -
hi fritz,
thanks for your answer!!!
I had tried "setNextKeyView" before, but now I figured out what I had
done wrong and it works like this:
NSEnumerator* enumerator;
NSView* subview;
NSView* lastSubview = nil;
enumerator = [[[mainWindow contentView] subviews] objectEnumerator];
while( subview = [enumerator nextObject] )
{
if ([subview isKindOfClass:[NSClipView class]]) {
if(lastSubview){
[[[subview subviews] objectAtIndex:0] seKeyView:[[lastSubview
subviews] objectAtIndex:0]];
}
lastSubview = subview;
}
}
it still needs a little tweaking (jumping back from the last field to
the first...) but this saves my day already....
regards,
jan
> On Sep 4, 2007, at 4:28 PM, Jan David Frölich wrote:
>
>> [H]ow do I set up the nextKeyView-order of a couple of
>> NSTextFields programmatically, when each NSTextField is located
>> inside its own NSClipView?
> ...
>> I want to make sure that tabbing between the Fields works as usual.
>> Searching the web and the archives wasn't sucessful for the last
>> days, so I hope somebody can help me here...
>
> You don't say whether you tried the setNextKeyView: method, and
> what the result was.
>
> — F
>



