[英]Clear state for SWT Text Widget
I have this function : 我有这个功能:
public static void changeState(Text control,final int style)
{
if (SWT.ENABLED == (style & SWT.ENABLED)) {
MyService.setState(control, SWT.ENABLED);
}
if (SWT.DISABLED == (style & SWT.DISABLED)) {
MyService.setState(control, SWT.DISABLED);
}
if(SWT.READ_ONLY == (style & SWT.READ_ONLY)){
MyService.setState(control, SWT.READ_ONLY);
}
}
I want to clear the current state of the widget before setting another state to it. 我想先清除小部件的当前状态,然后再为其设置其他状态。
I made a text object for which I set the state to inactive and after this I tried to set it to read_only but it didn't work and that's why I am trying to make a function which clears the current state in order to be able to change states for the same object. 我创建了一个文本对象,将其状态设置为非活动,然后尝试将其设置为read_only,但是它不起作用,这就是为什么我试图创建一个清除当前状态的函数以便能够更改同一对象的状态。
How should I do this? 我应该怎么做?
Maybe there is some function which does this but I couldn't find one. 也许有一些功能可以做到这一点,但我找不到。
There are no such flags as SWT.ENABLED
or SWT.DISABLED
. 没有诸如
SWT.ENABLED
或SWT.DISABLED
标志。
You enable/disable a control using 您可以使用以下方式启用/禁用控件
control.setEnabled(boolean);
You change the read only state of a Text
control using 您可以使用以下命令更改
Text
控件的只读状态
control.setEditable(boolean);
Note that most other style bits cannot be changed once a control has been created. 请注意,一旦创建控件,大多数其他样式位就无法更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.