Skip to content

Commit

Permalink
Fix for incorrect handling of click-event in FlxUIPopup
Browse files Browse the repository at this point in the history
  • Loading branch information
UncertainProd committed Nov 28, 2023
1 parent 81dd17d commit 9933109
Showing 1 changed file with 8 additions and 17 deletions.
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

0 comments on commit 9933109

Please sign in to comment.