I am trying to set the cursor position of SWT Text
to the end after appending string. I am aware of changing cursor position of SWT StyledText
, but not sure of SWT Text
. If you people have come across this Challenge and found the solution kindly share it.
Have a look at Text#setSelection(int)
:
public static void main(String[] args)
{
Display d = new Display();
final Shell shell = new Shell(d);
shell.setLayout(new GridLayout(1, false));
Text text = new Text(shell, SWT.BORDER);
text.setText("Some random text here...");
text.setSelection(text.getText().length());
shell.pack();
shell.open();
while (!shell.isDisposed())
while (!d.readAndDispatch())
d.sleep();
}
This will set the cursor to the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With