是否可以有一个带有事件处理程序的项目符号列表?
我正在使用 seesaw 在 Swing 中编写界面。
我想显示项目符号列表。单击某个项目时,我希望调用事件处理程序。
我已经设法让事件处理程序适用于组件/小部件,并且可以通过将 HTML 插入到标签中来轻松显示项目符号列表。我认为,如果没有其他可能,我可能需要捕获父级的鼠标单击事件并计算出偏移量。
拥有带有事件处理程序的可点击项目符号列表的最佳方式是什么?
I'm using seesaw to program an interface in Swing.
I want to display a bulleted list of items. When an item is clicked I want an event handler to be called.
I have managed to get event handlers working for components/widgets, and I can display a bulleted list easily by inserting HTML into a Label. I figure that if nothing else is possible I may need to capture mouse click events for the parent and work out offsets.
What's the best way to have a clickable bulleted list with event handlers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为最简单的方法是尽可能坚持使用小部件。考虑到不同的字体大小和小部件插入取决于平台,计算偏移量可能会变得非常困难。
如果您想要一个项目符号列表,为什么不简单地将项目符号图像放在每个标签前面。这样您就可以轻松收听每个单独标签上的事件。此外,您不会将自己限制在 seesaw 尚不支持的 HTML 上。
I think the easiest way would be to stick to widgets as much as possible. Working out offsets may become very difficult considering different font sizes and widget insets depending on platform.
If you want to have a bullet list, why not simply put a bullet image in front of every label. This way you could easily listen for events on every individual label. Also, you won't constrain yourself to HTML which seesaw has no support for yet.
MHOOO 的答案可能是最好的选择,但另一种选择是以只读、无边框的方式显示 HTML 编辑器窗格 并添加 超链接侦听器< /a>.我本可以发誓我会在某个时候添加对此的支持,但我想不会。它现在在列表中:)
更新:好的。超链接侦听器支持添加以及示例。当 1.3.1 发布时,它们将会出现。
MHOOO's answer is probably the best bet, but one other option is to display HTML in a read-only, borderless editor pane and add a hyperlink listener. I could have sworn I added support for that at some point, but I guess not. It's on the list now :)
Update: Ok. Hyperlink listener support added along with an example. They'll be in 1.3.1 when it comes around.