以编程方式不重视TextField? [英] Programmatically unfocus a TextField?

查看:165
本文介绍了以编程方式不重视TextField?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,我只有一个可编辑的内容:TextField中的文本。问题是,作为一个用户永远摆脱焦点(因为没有什么别的焦点),一旦TextField的重点。当用户按下Enter键时,我想从TextField中移除焦点。我知道如何对被按下的Enter键作出反应,但我不知道如何以编程方式忽略控件/ TextField?



感谢您的任何提示! 但是我收到了一个我想在这里分享的答案:

调用 requestFocus()在我的情况下,包含TextField的HBox。



https上的完整示例://forums.oracle.com/forums/thread.jspa?messageID = 10852574


On my view I only have one editable content: Text in a TextField. The problem is that as a user one never gets rid of the focus (because there is nothing else to focus on), once the TextField is focused. I want to remove the focus from the TextField when the user presses Enter. I know how to react to the Enter key being pressed, but I don't know how to unfocus a control/TextField programmatically?

Thanks for any hint!

解决方案

I admit I crossposted, but I got a reply there which I want to share here:

Call requestFocus() on the parent, e.g. in my case the HBox containing the TextField.

Full example on https://forums.oracle.com/forums/thread.jspa?messageID=10852574

这篇关于以编程方式不重视TextField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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