[英]How do you remove focus from an SWT widget control (such as Text)?
You cannot remove the focus from a Control
, ie unfocus it. 您不能从Control
移开焦点,也不能使其失去焦点。
As @Baz suggests, you can transfer the focus to another control with setFocus()
or forceFocus()
. 正如@Baz所建议的,您可以使用setFocus()
或forceFocus()
将焦点转移到另一个控件。 The latter gives focus to a Control
even if it has the SWT.NO_FOCUS
style, like Label
s do. 后者即使具有SWT.NO_FOCUS
样式(如Label
的样式),也将焦点放在Control
。
You can remove/transfer focus from a SWT Control(Text) in the following 2 ways: 您可以通过以下两种方式从SWT控件(文本)中删除/转移焦点:
setFocus()
method. 使用setFocus()
方法将焦点设置在其他控件上。 setEnabled(false)
method, but this will deprive the widget of its functionality. 您可以使用setEnabled(false)
方法禁用“控制”小部件,但是这将使小部件失去其功能。 Hence it's not recommended. 因此,不建议使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.