hyperandroid / CAAT

Canvas Advanced Animation Toolkit
hyperandroid.github.com/CAAT
MIT License
727 stars 117 forks source link

Triggering mouseDown on one actor disables mouseEnter on all other actors #118

Open superaniki opened 11 years ago

superaniki commented 11 years ago

I need this to work so I can push one checkmarker and then slide over the others for easy toggling of states. I find the disabling of the mouseEnter in this situation kind of unexpected.

I checked the source but found the functionality of dragging too nested. Felt that I might break something if I tried to fix it.

Any ideas for a quick workaround?

Great lib btw. =)

superaniki commented 11 years ago

Also, mouseMove becomes disabled for all actors under the same circumstances, so that can't be used for a workaround.

mouseOver seems totally dead also under all circumstances and probably needs an issue of its own.

hyperandroid commented 11 years ago

CAAT input control does not work that way. What i suggest you is delegating input to a container object, and then, upon mouse events on the container, identify what actors you are sending input to. There are built-in functions (actor.modelToModel) to transform an actor local coordinate into another actor's affine space local coordinate.

2013/1/24 Rickard Sandgren notifications@github.com

Also, mouseMove becomes disabled for all actors under the same circumstances, so that can't be used for a workaround.

mouseOver seems totally dead also under all circumstances and probably needs an issue of its own.

— Reply to this email directly or view it on GitHubhttps://github.com/hyperandroid/CAAT/issues/118#issuecomment-12652010.

superaniki commented 11 years ago

Thank you for your fast respons!

Hmm.. is this what you mean: I disable events in all of ActorContainers children. Upon mouseDown, I delegate the mouseEnter-event manually to its children making boundingbox-checks myself and by using the modelToModel function you suggested?

I still feel its kind of expected that something as general as a standard actor always should recieve mouseEnter, since, well, its the name of the event, and there is no documentation or anything to suggest the any special case for this not to happen, without looking at the code. If there is some concept in CAAT that I have missunderstood, or some documentation I have missed, please, I'm very happy to be corrected!

Anyway, I solved my problem by creating another eventfunction (mouseEnterAlways) by placing the following code at the beginning of the __mouseMoveHandler. It's hacky but I get the mouseEnter(Always) to always register, as I expect.


            lactor = this.findActorAtPosition(this.mousePoint);
            pos = lactor.viewToModel( new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));

            var contains = lactor.contains(pos.x, pos.y);

            if (!this.in_ && contains) {
                lactor.mouseEnterAlways(
                    new CAAT.Event.MouseEvent().init(
                        pos.x,
                        pos.y,
                        e,
                        lactor,
                        this.screenMousePoint,
                        ct));
                this.in_ = true;
            }