I have a class of this type org.eclipse.swt.widgets.Text. It lives inside of an eclipse plugin I am developing. I want to handle the event where the user selects text from within this field. That is… while focused, they click into some text and drag either left or right to select text. When this text is selected, that is when I need to fire my event.
I am yet unable to find the appropriate listener to cover my need.
I think
SWT.MouseUpis the event you are looking for. If you want to check “arrow keys and shift selection”, listen toSWT.KeyUpas well and check thekeyCodeof the event:This code will only print the selection, if the user really selected something. If it’s a mouse-up o key-up without selection, nothing will happen.
You might want to combine both in one listener to save space.