当画布在 Flex 3 中可见时,不允许单击画布下方的组件
我有一个组件(画布),上面有一个单击事件侦听器。但是,有时会在该组件上覆盖不透明的画布。当覆盖画布可见时,我不希望底层组件可单击。
有没有一种方法可以做到这一点,而无需在覆盖画布变得可见时手动删除单击事件侦听器,并在覆盖画布变得不可见时重新添加单击事件侦听器?
顺便说一句,有趣的是,覆盖画布包含标签元素,当覆盖画布可见时,底层组件只能在覆盖画布上没有标签元素的区域中单击。
另外,由于这是 Flex,我应该注意单击事件侦听器最初是通过 Actionscript 添加的,而不是通过 mxml 添加的。
I have a component (a canvas) that has a click event listener on it. However, there is sometimes an opaque canvas that lays over that component. When that overlaying canvas is visible, I don't want the underlying component to be clickable.
Is there a way to do this without manually removing the click event listener when the overlaying canvas becomes visible and adding back the click event listener when the overlaying canvas becomes invisible?
As a side note, interestingly enough, the overlaying canvas contains label elements and when the overlaying canvas is visible, the underlaying component is only clickable for the area of the overlaying canvas where there is not a label element.
Also, since this is Flex, I should note that the click event listener was originally added through Actionscript and not through mxml.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信你想要做的是在不透明画布上设置
mouseEnabled="true"
和useHandCursor="false"
。这应该会阻止任何鼠标事件“穿过”画布。I believe what you want to do is set
mouseEnabled="true"
anduseHandCursor="false"
on the opaque canvas. That should stop any mouse events to go 'through' the canvas.我很确定您是否设置了 mouseEnabled 和 mouseFocusEnabled 属性设置为 false,则画布将不会触发单击事件处理程序。
当然,我不认为画布(或任何容器)可以点击;所以要触发事件;画布内部必须有一些东西可以真正触发点击事件。我不确定 mouseEnabled 和 mouseFocusEnabled 属性是否会渗透到容器的子级。
I'm pretty sure if you set the mouseEnabled and mouseFocusEnabled properties to false, then the canvas will not fire the click event handler.
Of course, I didn't think canvases (or any Container) could be Clickable; so for the event to fire; there has to be something inside the canvas that actually fires the click event. I'm not sure if the mouseEnabled and mouseFocusEnabled properties trickle down to the container's children.
只需遮盖不透明画布,这样点击效果就不会覆盖在画布上
Just mask the opaque canvas so it wont be over the canvas with the click effect