如何更新 SWT 组合框中的项目列表?
我有一个带有组合框的用户界面。每次组合要打开列表时,都必须刷新可以选择的项目列表。
有没有什么方法 - 即添加一个侦听器来通知 UI Combo 即将打开?
不幸的是,我无法观察模型在更改时更新列表。
I have a UI with a Combo box. The list of items, which can be chosen, has to be refreshed every time the combo is about to open the list.
Is there any way - i.e. to add a listener which will inform UI that Combo is about to open?
Unfortunately I am not able to observe model to update the list when it changes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,SWT 组件没有这样的方法。在 Swing 中,借助 PopupMenuListener 接口会很容易。
我能想到的解决方法是实现一个 MouseListener 和一个 KeyboardListener (因为可以通过按“空格”打开组合框),这样您至少可以在这两个事件发生时更新您的组合框列表。
Unfortunatelly there is no such method for SWT Components. In Swing it would be easy with the help of the PopupMenuListener Interface.
A workaround I can think of would be to implement a MouseListener and a KeyboardListener (As Comboboxes can be opened by pressing 'space') so you can at least update your Combobox List when those two Events take place.