当复选框被选中/取消选中时,如何触发 Flex 列表中的 itemEditEnd 事件?
我有一个 List
组件,它具有嵌入式 CheckBox
itemEditor,它也充当 itemRenderer。 它将每个项目显示为带有标签的简单 CheckBox
。
但是,直到我单击列表之外的内容后,itemEditEnd 事件才会被触发。 我希望在选中或取消选中复选框后触发它。
我正在考虑在 CLICK 事件处理程序中手动调度 ListEvent.ITEM_EDIT_END ,但随后 itemEditEnd 事件将被调度两次。 一定有更好的方法来做到这一点。
有任何想法吗?
谢谢。
I have a List
component that has drop-in CheckBox
itemEditor that also serves as the itemRenderer. It displays each item as a simple CheckBox
with a label.
However, the itemEditEnd Event does not get triggered until I click on something outside of the List. I want it triggered once the CheckBox is checked or unchecked.
I was thinking of manually dispatching the ListEvent.ITEM_EDIT_END in a CLICK Event handler, but then the itemEditEnd Event would get dispatched twice. There's gotta be a better way to do this.
Any ideas?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我想出的解决方案。 我更改了列表以使用该组件仅作为 itemRenderer,而不是作为 itemRenderer 和 itemEditor。 然后,我添加了一个 MouseEvent.CLICK 处理程序,以从 itemRenderer 调用列表中的函数来执行必要的操作:
我的列表组件:
我的 ItemRenderer:
Here is the solution I came up with. I changed my List to use the component as an itemRenderer only, not as a itemRenderer and itemEditor. I then added a MouseEvent.CLICK handler to call a function in the List from the itemRenderer to perform the necessary actions:
My List Component:
My ItemRenderer:
我刚刚遇到这个。 我使用的是自定义组件而不是直接插入方法,这在使用渲染器作为编辑器时有效。
请注意,Flex 人员显然提出了这样的想法:用户希望在确定要提交的状态之前多次切换复选框……此时他们会按 Enter 键。 多么明显啊!
我的解决方案是合成一个相当于按 Enter 的键盘事件。 棘手的部分是必须使用 callLater() 方法来调度事件,因为在调用复选框的单击处理程序之前,列表控件不会在编辑器上注册其键盘侦听器。 这是我的自定义渲染器/编辑器组件中复选框的单击处理程序:
I've just run into this. I'm using a custom component rather than the drop-in approach, and this works when using the renderer as the editor.
Note that the Flex folks evidently came up with the notion that users would want to toggle their checkboxes a few times before settling on the state to commit to...at which point they'd hit the Enter key. How obvious!
My solution is to synthesize a keyboard event that is equivalent to hitting Enter. The tricky part is that one must use the callLater() method to dispatch the event because the list control won't have registered its keyboard listener on the editor until after the checkbox's click handler gets called. Here's my click handler for the checkbox in my custom renderer/editor component: