简体   繁体   English

如何在运行时启用/禁用SWT Text WRAP

[英]How to enable/disable SWT Text WRAP in runtime

I have a SWT button (with SWT.CHECK flag) and SWT Text. 我有一个SWT按钮(带有SWT.CHECK标志)和SWT文本。 Upon pressed, SWT button should enable/disable the wrapping of the SWT text. 按下后,SWT按钮应启用/禁用SWT文本的换行。

I am aware that text wrapping capability is specified in the constructor as follow: 我知道文本包装功能在构造函数中指定如下:

new Text(parent, SWT.WRAP)

But I couldn't find a method such as setWrap(false) to programmatically enable/disable it in runtime. 但是我找不到像setWrap(false)这样的方法来在运行时以编程方式启用/禁用它。

Is there a way to do this in SWT? 有没有办法在SWT中做到这一点? Or the only solution is to dispose the old text, and create a new one with different flag? 或者唯一的解决方案是处理旧文本,并创建一个具有不同标志的新文本?

In general SWT styles can't be changed and this is the case for the Wrap style of the Text control. 通常,SWT样式不能更改,这是Text控件的Wrap样式的情况。

The StyledText control does have a setWordWrap(boolean) method, you should be able to use that. StyledText控件确实有一个setWordWrap(boolean)方法,你应该可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM