Friday, September 3, 2010

Frustrating Flex problems solved #5 - ButtonBarButton bugs

So i had a series of custom Buttons all set up perfectly in a ButtonBar, when I realised that the design dictated that one of the buttons was a different size than was happening with the automatic sizing system...

So after discovering that the ButtonBar does not allow facility for resizing the width of a button, I had the choice. If i was going to extract the buttons from the ButtonBar, it probably would make sense to have them as a different type - Button for example. But reskinning my buttons as a different type could be time-consuming so I thought I'd see how I go just using ButtonBarButtons that aren't in a ButtonBar!

All turned out fine, except that my labels weren't appearing. A little delving into the code and I discovered the following code inside spark.components.supportClasses.ButtonBase:

// Push down to the part only if the label was explicitly set
if (_content !== undefined)
labelDisplay.text = label;

For my two cents, there's something strange going on there... So to set the label, I need to put the text inside the label property, and i need to ensure that content is not undefined. Set content to something arbitrary and the label appears! weird...

<s:ButtonBarButton label="Title" content="nada"/>

1 comment:

JabbyPanda said...

You could change the default layout specified in file from ButtonBarHorizontalLayout to the some custom layout.

For example, have a look at this implementation of Horizontal Multiline Layout by Max Kachurovskiy