Flexlib ScheduleViewer..如何处理项目的点击
我正在尝试使用 flexlib 计划查看器 在我的应用程序中。
我希望拥有它,以便当我单击预定事件时,它会调用我的主应用程序中的一个函数(这将允许我编辑事件)。但似乎没有任何特定的功能可以用于类中内置的任何类似功能,即当我单击事件时不会调度任何事件。
我可以使用“单击”功能来检测该项目是否已被单击..并尝试过类似的操作:
private function exerciseClickHandler(event:MouseEvent):void{
if (exerciseSeries.selectedItem != null){
//code
}
}
<code:ScheduleViewer id="exerciseSeries" click="exerciseClickHandler(event)" />
此方法不是很可靠,因为如果它只在第一次工作..一旦选择了一个项目,它就会保持选中状态,因此对该项目的所有后续点击都满足条件。
有没有办法判断某个事件是否被点击?
或者我是否必须扩展组件并在单击事件时添加某种 clickEvent 。
I'm trying to use a flexlib schedule viewer in my application.
I want to have it so that when I click on a scheduled event, it calls a function in my main app (that will allow me to edit the event). But there doesn't seem to be any specific function for anything like this built into the class ie no event dispatched when I click on an event.
I can use the 'click' function to detect that the item has been clicked on.. and have tried something like this:
private function exerciseClickHandler(event:MouseEvent):void{
if (exerciseSeries.selectedItem != null){
//code
}
}
<code:ScheduleViewer id="exerciseSeries" click="exerciseClickHandler(event)" />
This method isn't very reliable because if it only works the first time.. once an item is selected, it stays selected so all following clicks on the item fulfills the condition.
Is there any way to determine whether an event was being clicked on?
Or do I have to extend the component and add some sort of clickEvent when an event is clicked on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于当您单击该组件时,exerciseClickHandler 就会启动,这行不通?
而不是
写
或
我的意思是你写的是单击第一个元素后一切都会停止。根据您提供的代码,它必须停止,因为在第一次单击之后,exerciseSeries.selectedItem 将不再是 null,因为它已被选中。因此,删除您编写的条件并使用该实例。
Since exerciseClickHandler is firing up when you click on the component, wouldn't this work?
Instead of
write
or
What I mean is that you wrote that everything stops after the first element is clicked. And according to the code you provided it has to stop, beacuse after the first click
exerciseSeries.selectedItem
won't benull
anymore, since it's selected. So remove the conditional you wrote and use the instance.我建议您设置一个 ChangeWatcher 来关注 selectedItem(或者 selectedItems,如果您打算在某个时候允许多重选择)。示例:
另一种方法是每当用户单击时在鼠标坐标下的视图层次结构中搜索事件类的实例。
其中 EventClass 是表示事件的对象的类
I'd suggest you set up a ChangeWatcher to keep an eye on the selectedItem (or selectedItems if you are going to allow multiple selection at some point). Example:
An alternative would be to search for an instance of the the event class in the view hierarchy under the mouse coordinates whenever a user clicks.
Where EventClass is the class of the objects that represent events
我也遇到过类似的问题,有时您可以通过用 Box 包装对象并将单击事件放在 Box 上来解决。如果您还没有尝试过,这是一个便宜且简单的解决方案(如果它适合您)。
I have had similar problems and sometimes you can get by with wrapping the object with a Box and putting the click event on the Box. If you have not already tried that, it's a cheap, easy fix (if it works for you).