My Text is declared as,
Text text= new Text(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
It should be disabled in some cases. But when I do
text.setEnabled(false); the text's scroll bar gets disabled too and i am not able to see the value in the Text completely.
My Text Field cannot be READ ONLY. It should be editable in some cases.
I am aware of setEditable() method in Text, but I would like to have the same behaviour as when the Text is disabled i.e, background color change, no blinking cursor(caret), unable to do mouse clicks and the text being not selectable etc.
I was able to change the background color by doing
text.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
But i couldn't disable the cursor, text selection and the mouse click.
Is there a way to keep the scroll bar active for a disabled Text?
You won't be able to make the
Text
control show scrollbars when it'd disabled. It's just the way the native control works, i.e., the way the OS renders the controls.However, you can wrap your
Text
in aScrolledComposite
. That way, theScrolledComposite
will scroll instead of theText
.Here is an example:
This is what it looks like: