Skip to content

Commit

Permalink
allow tabbar to response to property changes on buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Feb 4, 2024
1 parent d436719 commit 41720b4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions haxe/ui/components/TabBar.hx
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ private class Builder extends CompositeBuilder {

}

private var _childToButtonMap:Map<Component, TabBarButton> = new Map<Component, TabBarButton>();
private function createTabBarButton(child:Component):TabBarButton {
var button = new TabBarButton();

Expand Down Expand Up @@ -471,9 +472,21 @@ private class Builder extends CompositeBuilder {
button.styleNames = child.styleNames;
}

_childToButtonMap.set(child, button);
child.registerEvent(UIEvent.PROPERTY_CHANGE, onButtonPropertyChange);

return button;
}

private function onButtonPropertyChange(event:UIEvent) {
if (event.data == "text") {
var button = _childToButtonMap.get(event.target);
if (button != null) {
button.text = event.target.text;
}
}
}

private override function get_numComponents():Null<Int> {
return _container.numComponents;
}
Expand Down

0 comments on commit 41720b4

Please sign in to comment.