Skip to content

Commit 17a4135

Browse files
committed
Merge branch 'master' of https://github.com/haxeui/haxeui-core
2 parents 1a1c573 + 9302f0a commit 17a4135

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

haxe/ui/containers/ButtonBar.hx

+17-4
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,32 @@ class ButtonBarBuilder extends CompositeBuilder {
151151
}
152152

153153
public override function addComponent(child:Component):Component {
154-
if ((child is Button)) {
154+
if (!child.hasClass("button-bar-divider")) {
155155
if (_bar.numComponents > 0) {
156156
var divider = new Component();
157157
divider.addClass("button-bar-divider");
158158
_bar.addComponent(divider);
159-
160159
}
160+
child.registerEvent(UIEvent.SHOWN, onButtonShown);
161+
child.registerEvent(UIEvent.HIDDEN, onButtonHidden);
162+
}
163+
if ((child is Button)) {
161164
if (_bar.selectedIndex == _bar.numComponents) {
162165
cast(child, Button).selected = true;
163166
}
164167
cast(child, Button).toggle = _bar.toggle;
165-
child.registerEvent(UIEvent.SHOWN, onButtonShown);
166-
child.registerEvent(UIEvent.HIDDEN, onButtonHidden);
168+
}
169+
170+
return null;
171+
}
172+
173+
public override function removeComponent(child:Component, dispose:Bool = true, invalidate:Bool = true):Component {
174+
if (!child.hasClass("button-bar-divider")) {
175+
var childIndex = _bar.getComponentIndex(child);
176+
var followingChild = _bar.getComponentAt(childIndex + 1);
177+
if (followingChild != null && followingChild.hasClass("button-bar-divider")) {
178+
_bar.removeComponent(followingChild, true, invalidate);
179+
}
167180
}
168181

169182
return null;

0 commit comments

Comments
 (0)