如何创建无法选择的只读 SWT 文本? (通过键盘和鼠标)
如何创建无法选择的只读 SWT 文本? (通过键盘和鼠标)
例如:
Text text = new Text(shell, SWT.BORDER | SWT.READ_ONLY);
text.append("text text text text text text text text text text text text text ");
text.setSelection(10, 60); // If only I could write here something that could turn the text impossible to select, just like if it were a label.
How can I create a read-only SWT text that is impossible to select? (by keyboard and mouse)
for example:
Text text = new Text(shell, SWT.BORDER | SWT.READ_ONLY);
text.append("text text text text text text text text text text text text text ");
text.setSelection(10, 60); // If only I could write here something that could turn the text impossible to select, just like if it were a label.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请改用标签。或者使用 Text 的
setEnabled
和setEditable
方法。Use a Label instead. Or use Text's
setEnabled
andsetEditable
methods.如果使用 Enablad 属性,您将无法从中复制文本。
In case Enablad property using you can`t copy text from it.
我建议做这个。您可以创建自己的包含两个文本框的widjet。我们可以将其命名为 OurTextBox。第一个创建为通常,第二个创建为只读(带有 SWT.READONLY 标志)。您可以使用 StackLayout 进行布局。然后你应该定义一些属性和方法。
这个的主要内容:
设置文本();获取文本();
设置只读();
当调用 SetReadonly 时,您可以显示两个内部文本框之一。
不幸的是,这是动态 ReadOnly 的唯一解决方案
I advise to make tihs. You can create yor own widjet that contain two text box. We may name it OurTextBox. The First created as usaly, second as readonly (with SWT.READONLY flag). You may use StackLayout for layout. Then you should define some properties and methods.
Main of this:
SetText(); getText();
SetReadonly();
When SetReadonly is invoked you can show one of two internal TextBox.
Unfortunately, this is the only solution to dynamically ReadOnly