@@ -151,19 +151,32 @@ class ButtonBarBuilder extends CompositeBuilder {
151
151
}
152
152
153
153
public override function addComponent (child : Component ): Component {
154
- if (( child is Button )) {
154
+ if (! child . hasClass ( " button-bar-divider " )) {
155
155
if (_bar .numComponents > 0 ) {
156
156
var divider = new Component ();
157
157
divider .addClass (" button-bar-divider" );
158
158
_bar .addComponent (divider );
159
-
160
159
}
160
+ child .registerEvent (UIEvent .SHOWN , onButtonShown );
161
+ child .registerEvent (UIEvent .HIDDEN , onButtonHidden );
162
+ }
163
+ if ((child is Button )) {
161
164
if (_bar .selectedIndex == _bar .numComponents ) {
162
165
cast (child , Button ).selected = true ;
163
166
}
164
167
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
+ }
167
180
}
168
181
169
182
return null ;
0 commit comments