SWT 光标文本

SWT cursor text

我需要在 Java 中使用 Text.setCursor(Cursor cursor);org.eclipse.swt.widgets.Text 控件的光标设置为正常的 "text-select-cursor"。默认值,即悬停此文本时。

正确的SWT常量是什么?我已经在 Google 上搜索过,但没有找到示例。

SWT.CURSOR_HAND 的代码示例:

Text text = new Text(parent, SWT.BORDER);
Cursor cursor = Display().getCurrent().getSystemCursor(SWT.CURSOR_HAND);
text.setCursor(cursor);
SWT.CURSOR_IBEAM

就是答案。

部分参考资料:


如果您只想将 Cursor 恢复为 Control 的默认值,只需调用 Control#setCursor(null):

Sets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.

Javadoc