Skip to content

Commit

Permalink
button bar can contain more than just buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Oct 8, 2024
1 parent 510f258 commit 718786e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions haxe/ui/containers/ButtonBar.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ private class SelectedIndex extends DataBehaviour {
return;
}

var button = cast(_component.getComponentAt(_value), Button);
var buttons = _component.findComponents(Button, 1);
var button = buttons[_value.toInt()];
if (currentButton == button) {
return;
}

if (currentButton != null && _value.toInt() < _component.numComponents) {
if (currentButton != null && _value.toInt() < buttons.length) {
builder._currentButton.selected = false;
}

Expand Down Expand Up @@ -116,7 +117,8 @@ private class Events extends haxe.ui.events.Events {

private function onButtonChanged(event:UIEvent) {
var button = cast(event.target, Button);
var index = _bar.getComponentIndex(button);
var buttons = _bar.findComponents(Button, 1);
var index = buttons.indexOf(button);
if (_bar.allowUnselection == false && index == _bar.selectedIndex && button.selected == false) {
button.selected = true;
return;
Expand Down

0 comments on commit 718786e

Please sign in to comment.