Skip navigation.
 
mlRe: NSTabView and edit fields
FROM : John Stiles
DATE : Tue Aug 01 17:30:40 2006

Matt Neuburg wrote:
> On Mon, 31 Jul 2006 13:54:48 -0700, John Stiles <<email_removed>> said:


>> I'd really appreciate it if someone would download my demo and see if
>> they notice anything obviously wrong with it. The code is dead simple:
>>
>> - (IBAction)goToFirstTab:(id)sender
>> {
>> [myTabView selectTabViewItemAtIndex:0];
>> }
>>
>> - (IBAction)goToSecondTab:(id)sender
>> {
>> [myTextField setStringValue:@""];
>> [myWindow makeFirstResponder:myWindow];
>> [myTabView selectTabViewItemAtIndex:1];
>> }
>>   

>
> (1) myWindow outlet was not hooked up, so second line was pointless.
>


Ah. That's what happens when you make a sample app in a hurry :)
> (2) the problem you're describing (the field has apparent focus but typing
> does nothing) is easily solved by using delayed performance:
>
> - (void) doIt: (id) dummy {
>    [myTabView selectTabViewItemAtIndex:1];
> }
>
> - (IBAction)goToSecondTab:(id)sender {
>    [myTextField setStringValue:@""];
>    [self performSelector:@selector(doIt:) withObject:nil afterDelay:0.1];
> }
>


I experimented with this---it worked on my machine but then I tried it
on a coworker's machine and it failed (the bug reappeared just like
before). So I don't know. He has full keyboard access enabled, and I
don't, and the machines likely have other differences which I didn't
notice as well. It certainly merits further experimentation.
> (3) The real bug here is, it seems to me, that the text field is not
> focussed at startup, since it is the only focusable thing in the window. The
> behavior otherwise (after the fix above) is right - the text field has focus
> when you return to the first tab view, because something must. m.


I don't think it's apparent that a control in the window /must/ have
focus. The window itself, or the window frame container, can have the
focus. That's perfectly legitimate AFAICS. And I certainly don't think
the impetus is on the developer to force focus on a control in a window
whenever you show a window or sheet---this certainly isn't a common
Cocoa programming technique.

Related mailsAuthorDate
mlNSTabView and edit fields John Stiles Jul 28, 04:15
mlRe: NSTabView and edit fields John Stiles Jul 31, 22:54
mlRe: Re: NSTabView and edit fields Wagner Truppel Jul 31, 23:45
mlRe: NSTabView and edit fields John Stiles Aug 1, 00:03
mlRe: NSTabView and edit fields Ricky Sharp Aug 1, 02:24
mlRe: NSTabView and edit fields John Stiles Aug 1, 02:53
mlRe: NSTabView and edit fields Matt Neuburg Aug 1, 17:14
mlRe: NSTabView and edit fields John Stiles Aug 1, 17:30
mlRe: NSTabView and edit fields Ricky Sharp Aug 1, 18:22
mlRe: NSTabView and edit fields Ricky Sharp Aug 1, 18:25
mlRe: NSTabView and edit fields Matt Neuburg Aug 1, 18:38
mlRe: NSTabView and edit fields John Stiles Aug 1, 19:09
mlRe: NSTabView and edit fields Matt Neuburg Aug 1, 19:35