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

Fix for incorrect handling of CLICK_EVENT in FlxUIPopup #259

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions flixel/addons/ui/FlxUIPopup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,20 @@ class FlxUIPopup extends FlxUISubState implements IFlxUIWidget
switch (id)
{
case FlxUITypedButton.CLICK_EVENT:
var str = "";
if (eventParams != null)
{
if ((eventParams[0] is String))
var buttonAmount:Int = Std.int(eventParams[0]);
if ((_parentState is IFlxUIState))
{
str = Std.string(eventParams[0]);
// This fixes a bug where the event was being sent to this popup rather than the state that created it
castParent().getEvent(CLICK_EVENT, this, buttonAmount, eventParams);
}

var buttonAmount:Int = Std.int(eventParams[0]);
if (str == "affirm" || str == "cancel" || str == "alt")
else
{
if ((_parentState is IFlxUIState))
{
// This fixes a bug where the event was being sent to this popup rather than the state that created it
castParent().getEvent(CLICK_EVENT, this, buttonAmount, eventParams);
}
else
{
// This is a generic fallback in case something goes wrong
FlxUI.event(CLICK_EVENT, this, buttonAmount, eventParams);
}
close();
// This is a generic fallback in case something goes wrong
FlxUI.event(CLICK_EVENT, this, buttonAmount, eventParams);
}
close();
}
}
super.getEvent(id, sender, data, eventParams);
Expand Down