javaeclipse-plugincursorswteclipse-api

Change cursor type in ITextEditor


How can I change the cursor type while the cursor is in an ITextEditor? Specifically, on an event trigger I want to change the cursor to a pointer (similar to what Ctrl+Hover does in the Java editor).

I've tried standard code such as this:

PlatformUI.getWorkbench().getDisplay().getActiveShell().setCursor(new Cursor(PlatformUI.getWorkbench().getDisplay(), SWT.CURSOR_HAND));

and this:

Display.getDefault().getActiveShell().setCursor(new Cursor(Display.getDefault(), SWT.CURSOR_HAND));

but neither is changing the cursor. I have been unable to find additional documentation this.

Any assistance would be appreciated.


Solution

  • I figured it out, you can set it through the text widget:

    StyledText textWidget = getSourceViewer().getTextWidget();
    textWidget.setCursor(textWidget.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));