[HTML5 - WebGL - Lime 5.4.0 - OpenFl 6.1.0] Shapes not getting MouseEvents

Hi,
I have found a problem/bug with custom shapes.
I have a Sprite and am drawing a button

switchBtn = new Sprite();
switchBtn.graphics.beginFill(0x000000, 0.7);
switchBtn.graphics.moveTo(0 , 0);
switchBtn.graphics.lineTo(45, 0);
switchBtn.graphics.curveTo(50, 0, 50,  5);
switchBtn.graphics.lineTo(50, 30);
switchBtn.graphics.lineStyle(1, 0xffffff);
switchBtn.graphics.lineTo(0, 30);
switchBtn.graphics.lineTo(0, 0);
switchBtn.graphics.endFill();

This is a button with a rounded angle and two marked white sides: if I apply MouseEvent listeners it behaves like it wasn’t there, events are not triggered, BUT… if I remove

switchBtn.graphics.lineStyle(1, 0xffffff);

it magically starts working, and all MouseEvents are triggered. This worked in AS3.

Have you tried separating the line and the fill? (I have no idea if this would help; it just seems like something to try.)

switchBtn = new Sprite();
switchBtn.graphics.beginFill(0x000000, 0.7);
switchBtn.graphics.moveTo(0 , 0);
switchBtn.graphics.lineTo(45, 0);
switchBtn.graphics.curveTo(50, 0, 50,  5);
switchBtn.graphics.lineTo(50, 30);
switchBtn.graphics.lineTo(0, 30);
switchBtn.graphics.lineTo(0, 0);
switchBtn.graphics.endFill();

switchBtn.graphics.lineStyle(1, 0xffffff);
switchBtn.graphics.moveTo(50, 30);
switchBtn.graphics.lineTo(0, 30);
switchBtn.graphics.lineTo(0, 0);

Yes, that is what I did:

beginFill
-> shape
endFill

beginFill
-> lineStyle
-> line
endFill

This way it works, but it is a workaround.

Tracking it here:

1 Like

Ok boss, thank you! :slightly_smiling_face: