JFace中的SourceViewer,关于光标及鼠标设置。

来源:互联网 发布:网络推广论文参考文献 编辑:程序博客网 时间:2024/05/27 09:47

JFace中的SourceViewer封装了 StyledText这个控件,该控件可以自由设置光标位置及鼠标形状。我们根据该控件来做设置: 


光标位置的设置,result是空间内容中光标所在偏移量(int):

sourceViewer.getTextWidget().setCaretOffset(result);  

sourceViewer.getTextWidget().setFocus(); 


鼠标图形的设置:

viewer.getTextWidget().setCursor(new Cursor(getDisplay().getCurrent(),SWT.CURSOR_HAND));

第二个参数为鼠标形状样式,可供使用的样式有:

SWT.CURSOR_ARROW
SWT.CURSOR_WAIT
SWT.CURSOR_CROSS
SWT.CURSOR_APPSTARTING
SWT.CURSOR_HELP
SWT.CURSOR_SIZEALL
SWT.CURSOR_SIZENESW
SWT.CURSOR_SIZENS
SWT.CURSOR_SIZENWSE
SWT.CURSOR_SIZEWE
SWT.CURSOR_SIZEN
SWT.CURSOR_SIZES
SWT.CURSOR_SIZEE
SWT.CURSOR_SIZEW
SWT.CURSOR_SIZENE
SWT.CURSOR_SIZESE
SWT.CURSOR_SIZESW
SWT.CURSOR_SIZENW
SWT.CURSOR_UPARROW
SWT.CURSOR_IBEAM
SWT.CURSOR_NO
SWT.CURSOR_HAND


原创粉丝点击