首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >skinned UIComponents如何捕获鼠标事件?

skinned UIComponents如何捕获鼠标事件?
EN

Stack Overflow用户
提问于 2009-07-29 03:23:19
回答 3查看 1.2K关注 0票数 1

如果我对Flex的理解是正确的,那么Flex中的皮肤就是作为子级添加到UIComponents中以创建对象的可视化表示的DisplayObjects。但是如果我对Flash事件模型的理解是正确的,如果在另一个之上有一个不透明的DisplayObject,鼠标事件将会转到最上面的DisplayObject。重叠的DisplayObject不会接收任何鼠标输入。

那么,带皮肤的Flex UIComponents到底是如何工作的呢?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2009-07-29 05:25:12

这个页面很好地解释了Flex中的事件机制:

http://livedocs.adobe.com/flex/3/html/help.html?content=events_08.html

我认为关键是MouseEvents默认情况下会出现泡沫。由于皮肤元素是作为组件显示列表(在“rawChildren”中)的子元素添加的,因此事件仍然会冒泡到父元素。

票数 1
EN

Stack Overflow用户

发布于 2010-11-22 23:32:42

由于皮肤中的部分是由组件添加的,因此它具有确保您不能单击图形的功能,如果您查看Button扩展的ButtonBase类,您可以看到解释这一点的注释:

代码语言:javascript
复制
 // DisplayObjectContainer properties.
    // Setting mouseChildren to false ensures that mouse events
    // are dispatched from the Button itself,
    // not from its skins, icons, or TextField.
    // One reason for doing this is that if you press the mouse button
    // while over the TextField and release the mouse button while over
    // a skin or icon, we want the player to dispatch a "click" event.
    // Another is that if mouseChildren were true and someone uses
    // Sprites rather than Shapes for the skins or icons,
    // then we we wouldn't get a click because the current skin or icon
    // changes between the mouseDown and the mouseUp.
    // (This doesn't happen even when mouseChildren is true if the skins
    // and icons are Shapes, because Shapes never dispatch mouse events;
    // they are dispatched from the Button in this case.)
票数 2
EN

Stack Overflow用户

发布于 2010-02-07 17:54:59

您应该仍然能够将MouseEvent侦听器添加到主机组件-最好的示例是带皮肤的按钮。您可以像对待任何其他按钮一样对待它。

但是,在更复杂的皮肤组件中,需要向宿主组件中的各个皮肤组件添加侦听器。但是,这些事件也应该冒泡到主机组件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1197903

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档