... | @@ -52,8 +52,8 @@ Writing such a component is not extremely hard but also requires some thinking. |
... | @@ -52,8 +52,8 @@ Writing such a component is not extremely hard but also requires some thinking. |
|
* Managing horizontal and vertical scrollbars if required
|
|
* Managing horizontal and vertical scrollbars if required
|
|
* Cleaning up everything once the widget is no longer used
|
|
* Cleaning up everything once the widget is no longer used
|
|
* Displaying a mouse cursor in the correct shape as long as it is located over the editor
|
|
* Displaying a mouse cursor in the correct shape as long as it is located over the editor
|
|
* Displaying the text in different Fonts (that is the type, its size and styling)
|
|
|
|
* Allowing the user to wrap the editor lines, based on the current size of the widget
|
|
* Allowing the user to wrap the editor lines, based on the current size of the widget
|
|
|
|
* Displaying the text in different Fonts (that is the type, its size and styling)
|
|
* Managing the caret and displaceing it whenever a click happens to a different location
|
|
* Managing the caret and displaceing it whenever a click happens to a different location
|
|
|
|
|
|
|
|
|
... | @@ -274,7 +274,27 @@ A futher cool feature is to display the text curosr of the mouse as long as the |
... | @@ -274,7 +274,27 @@ A futher cool feature is to display the text curosr of the mouse as long as the |
|
});
|
|
});
|
|
```
|
|
```
|
|
|
|
|
|
First we need to get access to our two different cursor and second, we need to swap them in the correct moments.
|
|
First we need to get access to our two different cursor and second, we need to swap them in the correct moments. It is notable that the Curosr reference should be disposed using the dispose listener accordingly.
|
|
|
|
|
|
|
|
## Allowing the user to wrap the editor lines, based on the current size of the widget
|
|
|
|
|
|
|
|
Now we are reaching one of the more interesting steps of writing a text widget - line wrapping. For this purpose we should store a boolean variable in our widget ```useWrap```. If this boolean is set, we would wrap all incoming text, else we would display the lines in their full length and would add a horizontal scrollbar to our widget if necessary.
|
|
|
|
|
|
|
|
Wrapping lines is first interesting if the we receive a new input document. Recap the code of the ```setInput``` method:
|
|
|
|
|
|
|
|
public void setInput(CASEditorInput input) {
|
|
|
|
this.currentInput = input;
|
|
|
|
|
|
|
|
initLayout();
|
|
|
|
initData();
|
|
|
|
initEventHandler();
|
|
|
|
|
|
|
|
// refresh the widget
|
|
|
|
updateScrollbar();
|
|
|
|
drawWidget();
|
|
|
|
|
|
|
|
// and start the cursor
|
|
|
|
startCursor();
|
|
|
|
|
|
|
|
}
|
|
To be continued... |
|
To be continued... |
|
|
|
\ No newline at end of file |