Home » Eclipse Projects » Remote Application Platform (RAP) » How to change icon and overwrite builtin event code of SWT.ICON_CANCEL in a Text control?(in order to achieve a specific function by replacing SWT.ICON_CANCEL in a Text control)
How to change icon and overwrite builtin event code of SWT.ICON_CANCEL in a Text control? [message #1772844] |
Sun, 17 September 2017 06:56 |
David Lee Messages: 83 Registered: May 2013 |
Member |
|
|
Hi,
By using style SWT.SEARCH + SWT.ICON_SEARCH, we can see an "eraser" icon on the right of a Text control, and clear all content of the Text by clicking the icon.
If I want to change its behavior, my questions are:
1.How to change "eraser" icon to be another one(eg. SWT.ICON_INFORMATION or a self design icon)?
2.How to show a message box instead of clearing content of the Text control after click? (without clearing the content of the Text)
Thank you!
Best,
David
[Updated on: Sun, 17 September 2017 08:13] Report message to a moderator
|
|
| |
Re: How to change icon and overwrite builtin event code of SWT.ICON_CANCEL in a Text control? [message #1772901 is a reply to message #1772866] |
Mon, 18 September 2017 13:54 |
David Lee Messages: 83 Registered: May 2013 |
Member |
|
|
Hi,Ivan,
Thank you for your quick reply!
For a certain reason, I am trying to keep the text on a Text as it is after clicking eraser icon, and use the erase click event to do something else.
---------
protected SelectionListener selectionListener = new SelectionAdapter() {
@Override
public void widgetDefaultSelected( SelectionEvent event ) {
if( event.detail == SWT.ICON_CANCEL )
System.out.println( "ICON_CANCEL clicked" )
}
};
Text myText = new Text(...);
myText.setText("Hello!");
myText .addSelectionListener(selectionListener); // register selectionListener
----------
Code above ALWAYS erases text "Hello!" on myText BEFORE showing "ICON_CANCEL clicked" on cancel icon click.
Is there any way to keep the text on Text (ie. get rid of being defaultly erased) on cancel icon click?
Thank you for your guidance!
Best
David
[Updated on: Mon, 18 September 2017 15:42] Report message to a moderator
|
|
| | | | |
Goto Forum:
Current Time: Wed Feb 05 18:02:07 GMT 2025
Powered by FUDForum. Page generated in 0.03496 seconds
|