Re: Programmatically switching text fields
Re: Programmatically switching text fields
- Subject: Re: Programmatically switching text fields
- From: Ken Thomases <email@hidden>
- Date: Sun, 02 Aug 2015 23:28:22 -0500
On Aug 2, 2015, at 11:01 PM, Graham Cox <email@hidden> wrote:
> On 3 Aug 2015, at 12:13 pm, Ken Thomases <email@hidden> wrote:
>>
>> You can try [[self window] selectKeyViewFollowingView:control] instead.
>
> Great! That works fine.
Glad to hear it.
> The only problem remaining then is that the first field isn’t properly selected when the window shows up - it is initialFirstResponder and gets the key focus ring, but you can actually type text until you click in it again.
>
>> Are you certain the window is key? Does your app do anything unusual with activationPolicy or activation, generally?
>
> I don’t do anything unusual that I can see - it’s a fairly simple NSPanel.
The default implementation of -canBecomeMainWindow returns NO for panels. Is your window intended to be the main window? Is it actually? Does it change anything if you add an override to return YES?
> Thinking further, I do have a NSTabView between the window and these fields, and the tab on which the fields are placed are not on the default tab. I seem to recall there were issues with tab views a long time ago, and perhaps it’s naive to assume they’re fixed. It’s also probable that setting initialFirstResponder to an item that’s not on the displayed tab might fail, though it’s weird that it leaves it in a half-selected state. I’ll look at responding to the tab delegate methods to select the field when the tab is switched.
Are you aware that NSTabViewItem has its own initialFirstResponder property? Have you tried using that?
Regards,
Ken
_______________________________________________
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