避免在NSTextField上出现第一响应者的问题 [英] Problem avoiding first responder on a NSTextField

查看:127
本文介绍了避免在NSTextField上出现第一响应者的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在一个非常简单的应用程序中更改输入字段的行为:

I need to change behavior of input fields in a really simple app:

每当我启动该应用程序时,第一个文本字段都会成为焦点,但是我不希望出现这种情况。

Whenever i launch the application the first text field get the focus, but i don't want this behavior.

我尝试在IB中选中拒绝第一响应者。它可以使用,但是选中此选项后,我无法按制表符按钮在输入字段之间移动。

I tried checking "Refuses first responder" in IB. It works but with this option checked i can't move between input fields pressing "tab" button.

我应该怎么做才能避免专注于启动并保持使用Tab键移动的能力?

What can i do to avoid focus at startup and keep the ability to move with tab keyboard button ?

推荐答案

(先前)接受的答案不可靠,并且效果不佳。隐藏的 NSTextField 的另一个答案也不是很好,因为现在您的Tab顺序中有一个新元素。

The (previously) accepted answer isn't reliable and doesn't work very well. The other answer with the hidden NSTextField isn't very great either because now you have a new element in your Tab order.

到目前为止,我找到的最佳解决方案是:

The solution I've found works best so far is:

使 NSTextField拒绝FirstResponder 在应用启动时。

然后,在控制器的 viewDidAppear 中,然后将 refusesFirstResponder 设置回 NO

Then, in viewDidAppear for the controller, go ahead and set refusesFirstResponder back to NO.

启动后一切都变得完美,我没有贪婪的 NSTextField 在应用启动时偷走第一响应者。

Everything behaves perfect after launch, and I don't have a greedy NSTextField stealing first responder on app startup.

这篇关于避免在NSTextField上出现第一响应者的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆