Lee Loftiss
Lee Loftiss

Reputation: 3195

Canvas Scrolling

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.

Upvotes: 0

Views: 531

Answers (1)

Clay Parker
Clay Parker

Reputation: 31

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.

Upvotes: 1

Related Questions