Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxMouseEventManager: correct the mouseChildren parameter, closes #2102 #2110

Merged
merged 7 commits into from
Mar 31, 2018
Merged

FlxMouseEventManager: correct the mouseChildren parameter, closes #2102 #2110

merged 7 commits into from
Mar 31, 2018

Conversation

MSGhero
Copy link
Member

@MSGhero MSGhero commented Sep 10, 2017

Closes #2102

Fixes a bug with mouseChildren in FlxMouseEventManager where items with the parameter set to false still allowed overlapping objects to receive events. E.g. the children of a parent sprite group with mouseChildren = false still received events if they were added to FlxMEM after.

I forgot I made this change I've been using this change since the issue and haven't had any problems. It does break the order of the objects if that's a concern, which I could change but would be more involved.

@Gama11 Gama11 added the Bug label Sep 10, 2017
@Gama11
Copy link
Member

Gama11 commented Sep 10, 2017

I would also like to have a unit test for this, if possible.

@MSGhero
Copy link
Member Author

MSGhero commented Oct 6, 2017

reorder also needs to be changed since it disrupts the add order.

I'd like for sprite groups with mouseChildren = false to block their children's potential mouseChildren = false, drawing from how Flash does it. So this needs a bit more imo.

@MSGhero
Copy link
Member Author

MSGhero commented Oct 8, 2017

Essentially, the mouseChildren false and true objects should be in two separate arrays, or one array where the boundary between the two halves is managed. Adding an object or changing the mouseChildren param should place that object at the front of its proper subarray, which preserves the user's order.

@Gama11 my breaking question is if Flx(Sprite)Groups should block their children from receiving events like AS3's mouseChildren, which is not the case currently. That would have to go into reorder because I'm not really sure how to accomplish that in add without just calling reorder.

@MSGhero
Copy link
Member Author

MSGhero commented Jan 28, 2018

Will unit test, but the most recent commit keeps mouseChildren = true consistent with = false in terms of the add order.

@Gama11
Copy link
Member

Gama11 commented Mar 22, 2018

What's the status here? Is that Flx(Sprite)Group question still relevant?

@MSGhero
Copy link
Member Author

MSGhero commented Mar 24, 2018

Ehhhhh if you want it to be. Finding some time this and next weekend to code.

@MSGhero
Copy link
Member Author

MSGhero commented Mar 24, 2018

Ok

var sprites = [sprite3, sprite1, sprite2, sprite0];
for (i in 0...sprites.length)
{
Assert.areEqual(sprites[i], FlxMouseEventManager._registeredObjects[i].object);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really hacky, a unit test shouldn't need to rely on @:access(), only public API.

the parameter set to false still allowed overlapping objects to receive events.

You should be able to test for that not happening anymore?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(you should be able to dispatch mouse events manually, similar to what we do here:
https://github.com/HaxeFlixel/flixel/blob/dev/tests/unit/src/flixel/input/gamepad/FlxGamepadManagerTest.hx)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh I didn't think of that. That's a much better test, yeah.

Also allows re-setting mouseChildren to reorder sprites
@MSGhero
Copy link
Member Author

MSGhero commented Mar 31, 2018

Ok, again.

@Gama11
Copy link
Member

Gama11 commented Mar 31, 2018

Nice, that's much cleaner. 👍

@Gama11 Gama11 changed the title Correct the mouse children parameter FlxMouseEventManager: correct the mouse children parameter, closes #2102 Mar 31, 2018
@Gama11 Gama11 changed the title FlxMouseEventManager: correct the mouse children parameter, closes #2102 FlxMouseEventManager: correct the mouseChildren parameter, closes #2102 Mar 31, 2018
@Gama11 Gama11 merged commit 07cb77d into HaxeFlixel:dev Mar 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants