Search code examples
eclipsecomponentsrcp

Eclipse RCP Clear Button in Textinput


I just started working on an eclipse RCP application in my company and search now for following component:

In the eclipse preference dialog is a text input field with a eraser which clears the text box (see image).

enter image description here

Is there a component in eclipse RCP which does exactly that? Or one where I can set an image in a text input field, so I can implement just the functionality.

Or have I to write my own component extending from Text?

Thanks.


Solution

  • Eclipse does not offer such a component, so you will have to implement one yourself.

    But I wouldn't extend Text for this. Simply create a Composite with SWT.BORDER style, and a Text and Button as children. If you don't give the Text a border, it looks like the button is within the text box. Instead of the Button you could use a ToolBar with a single ToolItem, both with the SWT.FLAT style. This will look much better than a regular button.