Tokens in TextFields SWT

I am currently developing an Eclipse4 RCP application, and I was wondering if it is possible to define tokens in SWT text fields so that they are not accessible by symbol.

So, for example, I have a text box, and I want to make markers that match " [anytext] " not accessible by character. (Where the brackets define the token)

This means: I can’t put the cursor in the parenthesis, and if I press the delete button directly in front of the left bracket or backspace right behind the right bracket, the entire token is deleted.

I am currently doing this with listeners, but it seems a bit complicated and expensive, since I need a KeyListener with a lot of logic and a mouse listener to prevent clicks inside the marker and set Drop Listener as Drops inside the token should not be allowed obviously.

Did I just skip some fancy way of doing this?

Hope you help me, thanks!

+3
source share
1 answer

I suggest you use org.eclipse.swt.custom.StyledTextone that provides rich functions than org.eclipse.swt.widgets.Text. JavaEditor performs the same functions as you, as the name of a variable changing the name of a refactoring changes if the variable is used.

+1
source

All Articles