Textinput 中的 Eclipse RCP 清除按钮
我刚刚开始在公司开发 Eclipse RCP 应用程序,现在搜索以下组件:
在 Eclipse 首选项对话框中,有一个带有橡皮擦的文本输入字段,可以清除文本框(见图)。
eclipse RCP 中是否有一个组件可以完全执行此操作?或者我可以在文本输入字段中设置图像,这样我就可以实现功能。
或者我必须编写自己的从 Text 扩展的组件吗?
谢谢。
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).
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Eclipse 不提供这样的组件,因此您必须自己实现一个。
但我不会为此扩展
Text
。只需创建一个具有SWT.BORDER
样式的Composite
,以及一个Text
和Button
作为子项。如果您没有为Text
提供边框,则按钮看起来就像位于文本框中。您可以使用带有单个ToolItem
的ToolBar
来代替Button
,两者都具有 SWT.FLAT 样式。这看起来比普通按钮要好得多。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 aComposite
withSWT.BORDER
style, and aText
andButton
as children. If you don't give theText
a border, it looks like the button is within the text box. Instead of theButton
you could use aToolBar
with a singleToolItem
, both with the SWT.FLAT style. This will look much better than a regular button.这存在于 Luna 的 API 中,不知道旧版本是否如此。您可以在此处查看更多信息: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/ Snippet309.java?view=co
This is present in Luna's API, don't know about older versions. You can check more here: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet309.java?view=co