画布滚动

发布于 2024-11-07 06:00:28 字数 469 浏览 0 评论 0原文

我有一个 Canvas,里面有一个 VGroup,里面填充了各种类型的对象,其中一些具有 mouseEvents,例如 MOUSE_OVER。

我遇到的问题是让画布用鼠标滚轮正确滚动。仅当鼠标位于滚动条上时它才起作用。

我尝试通过监听舞台上的鼠标滚轮来伪造它,然后手动滚动画布。但是,当画布滚动到鼠标下的对象移动的位置时,事情就会变得棘手。

有什么建议吗?

小心, 李

更新:

好的。我发现,如果我在没有添加的情况下使用画布,则仅当鼠标位于其中的对象上方时它才会滚动。如果鼠标位于空白区域,则不会滚动。

当我说“鼠标位于其中的对象上方”时,我指的是文本字段和其他具有视觉元素的对象。

好的。我找到了部分解决方案。如果我拦截 VGroup 上的 mouseWHeel 事件,滚动就会起作用。但是,当我到达 VGroup 中的 RichEditableText 对象时,滚动停止。之前,它滚动得很好。

I have a Canvas with a VGroup inside that is populated with objects of various types, some of which have mouseEvents such as MOUSE_OVER.

The problem I am having is getting the Canvas to scroll properly with the mouse wheel. It will only work if the mouse is over the scrollbars.

I tried faking it by listening for the mouse wheel on the stage, then manually scrolling the Canvas. But when the the Canvas scrolls to where an object moves under the mouse, things get screwey.

Any suggestions?

take care,
lee

UPdate:

Ok. I found that if I use the canvas without my addition, it scrolls only when the mouse is over an object inside it. If the mouse is in an empty area, it does not scroll.

When I say 'the mouse is over an object inside it', I mean text fields and other objects that have visual elements.

Ok. I've found a partial solution. If I intercept the mouseWHeel event on the VGroup, the scrolling works. However, when I get to a RichEditableText object in the VGroup, the scrolling stops. Before, it scrolled just fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柳若烟 2024-11-14 06:00:28

在这里找到了一个有趣的解决方案。 mouseWheel 事件不会在画布中触发,除非它位于 InteractiveObject(即文本字段等)上。但是,当我进行测试以确保鼠标实际上位于画布中时,我发现该事件是在“白色”空间中触发的如果画布设置了背景颜色属性,则在对象之间。因此,设置backgroundColor,如果您不需要背景,则将backgroundAlpha 设置为0。

Found an interesting solution here. The mouseWheel event is not triggered in a canvas unless it is over an InteractiveObject, i.e. text fields etc. However, as I was testing to make sure my mouse was actually in the canvas I discovered that the event is triggered in the 'white' space between objects if the canvas has it's backgroundColor property set. So, set that backgroundColor and, if you didn't want a background, then set backgroundAlpha to 0.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文