Mouse events on children not fired

Bug #941644 reported by fuzzyTew
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
jeash
Fix Committed
Undecided
Niel Drummond

Bug Description

A DisplayObjectContainer with mouseEnabled = true containing no graphics, but containing child Shapes, will not fire mouse events when the mouse moves over the children.

Revision history for this message
fuzzyTew (fuzzytew) wrote :
description: updated
Revision history for this message
Niel Drummond (niel-drummond) wrote :

If I understand correctly, shapes do not receive input events:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Shape.html

Are there exceptions to this rule ?

Revision history for this message
fuzzyTew (fuzzytew) wrote :

Hi,

Shapes do not receive input events, but their parents do. The geometry of all your children should be included in your hit area.

The DisplayObjectContainer should receive mouse events when the mouse interacts with the graphics area of its children i.e. clicking a child Shape triggers MOUSE_DOWN on the parent DisplayObjectContainer. It does this in Flash but not in Jeash.

Revision history for this message
Niel Drummond (niel-drummond) wrote :

Please provide test case. The following test case works as described:

import flash.display.Shape;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.Lib;

class HitTestShape extends Sprite {

        static function main() {

                Lib.current.stage.addChild(new HitTestShape());
        }

        public function new() {
                super();

                var s = new Sprite();

                s.graphics.beginFill(0xCCFFAA);
                s.graphics.drawRoundRect(60, 60, 80, 80, 40, 40);
                s.name = "container";

                var sh = new Shape();
                sh.graphics.beginFill(0xAACCFF);
                sh.graphics.drawCircle(100, 100, 20);
                sh.name = "child";

                s.addChild(sh);
                addChild(s);

                s.addEventListener(MouseEvent.CLICK, function (_) trace(_.target));
        }
}

Revision history for this message
fuzzyTew (fuzzytew) wrote :

import flash.display.Shape;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.Lib;

class HitTestShape extends Sprite {

        static function main() {

                Lib.current.stage.addChild(new HitTestShape());
        }

        public function new() {
                super();

                var s = new Sprite();

                var sh = new Shape();
                sh.graphics.beginFill(0xAACCFF);
                sh.graphics.drawCircle(100, 100, 20);
                sh.name = "child";

                s.addChild(sh);
                addChild(s);

                s.addEventListener(MouseEvent.CLICK, function (_) trace(_.target));
        }
}

Revision history for this message
Niel Drummond (niel-drummond) wrote :

A fix for this edge case was committed.

Changed in jeash:
status: New → Fix Committed
assignee: nobody → Niel Drummond (niel-cyanescent)
milestone: none → 0.8.8
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.