Flex CSS LinkBar ToggleButtonBar Selected Text Color

Wouldn’t any reasonable coding human assume textSelectedColor to be the color of the text of the selected button in a Flex LinkBar or ToggleButtonBar?

After trying every possible ‘selected’ or ‘active’ CSS tag know to man (actually to Flex), and tracking down every possible path of  inheritance, I embraced one of my coding standards: counter-intuitive measures often prevail over reasonable assumptions.

To my dismay, disabledColor was the ticket. It has nothing to do with the selected state and unlike textRolloverColor and textSelectedColor, it has no mention of ‘text’!

So if I had been smart enough to assume that a selected button is actually disabled, I would have been fine. So when you want to dress up your selected button in your LinkBar/ToggleButtonBar with all kinds of nice-nices, just remember that LinkBar and ToggleButtonBar buttons operate like politicians – just because you’ve been selected does not imply that you’re enabled.

LinkButton
{
textRollOverColor: #006699;
textSelectedColor: #003366;
/* Yes, this one controls the selected button's text color */
disabledColor: #0099cc;

/*Use DownSkin for Disabled to simulate Active/Selected Button */
disabledSkin: Embed(source="theme1.swf", symbol="LinkButton_downSkin");
downSkin: Embed(source="theme1.swf", symbol="LinkButton_downSkin");
overSkin: Embed(source="theme1.swf", symbol="LinkButton_overSkin");
upSkin: Embed(source="theme1.swf", symbol="LinkButton_upSkin");
font-size: 14;
font-weight: bold;
}

  1. THANK YOU! I was pulling my hair out over that for an hour.

    I’ve also had a problem with the backgroundAlpha on the linkbar, it doesn’t seem to work.

    My solution (at least to make it transparent) was:

    LinkBar{
    borderSkin:ClassReference(null);
    }

    if anyone else is having that problem…

    • stefan
    • April 24th, 2010

    thanks! I was looking for the same…

    • Andrew
    • June 22nd, 2010

    Nice – you’re post cracked me up. I run Flex issues like that constantly.

    So what does “textSelectedColor” actually do?

    • Andrew
    • June 22nd, 2010

    I’m not sure about a linkbar but this solution doesn’t work with a ToggleButtonBar (the following will not work).

    ToggleButtonBar {
    textRollOverColor: #006699;
    textSelectedColor: #003366;
    disabledColor: #FF0000;
    font-size: 14;
    font-weight: bold;
    }

    • Andrew
    • June 23rd, 2010

    And just a little update from the last post, to set the text color of a selected button, you need to add the property ” selectedButtonTextStyleName” to the ToggleButtonBar CSS. Something like this:

    ToggleButtonBar {
    buttonStyleName: “mytoggleButtonBarButtonStyle”;
    firstButtonStyleName: “mytoggleButtonBarFirstButtonStyle”;
    lastButtonStyleName: “mytoggleButtonBarLastButtonStyle”;
    selectedButtonTextStyleName: “mytoggleButtonBarSelectedButtonStyle”;
    }

    .mytoggleButtonBarButtonStyle {
    }

    .mytoggleButtonBarFirstButtonStyle {
    }

    .mytoggleButtonBarLastButtonStyle {
    }

    .mytoggleButtonBarSelectedButtonStyle {
    color: #ffffff;
    fontSize: 12;
    fontWeight: normal;
    fontStyle: normal;
    textDecoration: none;
    }

    • Aditya
    • July 20th, 2010

    Hi..thanks a ton for this… I was looking for this for sometime now.

  2. Thanks so much, i was racking my brains over this for ages !

    • John Childress
    • August 31st, 2010

    Dude, thank you soo much… spent about 45 mins looking for this… aghh!!!!!

    • tianglim
    • September 7th, 2010

    Thanks man, i just spent two hours trying to figure this out… I almost tried every method!

    • Vishwa
    • March 3rd, 2011

    Hi thanx,
    Searching for the this fix for a long time…But one query
    What is this

    source=”theme1.swf”

    Shld i have a theme1.swf

    Regards
    vishwa

  3. THANK YOU!

    this has driven me mental for ages. good find

    glenn

    • Robert
    • January 3rd, 2012

    I know this is a little old, but I don’t know that you can blame flex for this. It follows CSS conventions that HTML programmers are used to. I do wish, however, that they would have made an effort to break from convention and make it make sense….

    • Eric
    • September 23rd, 2012

    Thanks a lot for this. Like everyone else before, I spent a lot of time on this before I stumble on your blog. What I would also like to do is to put the ‘disabled’ button in bold while the rest of the bar would remain normal. Any idea how to do this as there is no ‘disabledFontWeight’.

  1. No trackbacks yet.

Leave a comment