... | @@ -247,4 +247,34 @@ Coming back to our initial problem, keeping in mind what we just learned, we nee |
... | @@ -247,4 +247,34 @@ Coming back to our initial problem, keeping in mind what we just learned, we nee |
|
```
|
|
```
|
|
During this view we store a color that we use to display the selection of text, this handler assures that this resource is not lost!
|
|
During this view we store a color that we use to display the selection of text, this handler assures that this resource is not lost!
|
|
|
|
|
|
|
|
## Displaying a mouse cursor in the correct shape as long as it is located over the editor
|
|
|
|
|
|
|
|
A futher cool feature is to display the text curosr of the mouse as long as the mouse hovers over the widget. And as soon as the mouse exits we should reset the cursor to the standard. For this purpose there is a ```MouseTrackListener``` that ships with SWT. This listener has three methods of which we utilize two for the purpose of changing the cursor once the mouse enters. The third method is omitted for clarity.
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
|
|
|
this.addMouseTrackListener(new MouseTrackListener() {
|
|
|
|
|
|
|
|
// TODO store as global and dispose them again
|
|
|
|
private Cursor cursorText = new Cursor(Display.getCurrent(), SWT.CURSOR_IBEAM);
|
|
|
|
private Cursor cursorRegular = new Cursor(Display.getCurrent(), SWT.CURSOR_ARROW);
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mouseExit(MouseEvent e) {
|
|
|
|
// set to defautl cursor
|
|
|
|
ATHENEditorWidget.this.setCursor(cursorRegular);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mouseEnter(MouseEvent e) {
|
|
|
|
ATHENEditorWidget.this.setCursor(cursorText);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
First we need to get access to our two different cursor and second, we need to swap them in the correct moments.
|
|
|
|
|
|
|
|
|
|
To be continued... |
|
To be continued... |
|
|
|
\ No newline at end of file |