简体   繁体   English

Flex LinkBar:如何设置所选按钮的背景色?

[英]Flex LinkBar: how to set a selected button's background color?

I was able to set the text color of a selected LinkBar button by "disabledColor" style of LinkBar. 我能够通过LinkBar的“ disabledColor”样式设置所选LinkBar按钮的文本颜色。 Accordingly, I expect to set the background color of the selected button by "backgroundDisabledColor" style, however, it didn't work; 因此,我希望通过“ backgroundDisabledColor”样式来设置所选按钮的背景颜色,但是它不起作用。 and except "backgroundDisabledColor", I didn't see any other style that could possibly achieve this. 除了“ backgroundDisabledColor”外,我没有看到任何其他可能实现此目的的样式。 Please help. 请帮忙。 Thanks. 谢谢。

The problem is probably that you're setting the style on the LinkBar itself - try setting the LinkBar's linkButtonStyleName style to a different style selector that contains all of the styles you need for your button. 问题可能是您在LinkBar本身上设置了样式-尝试将LinkBar的linkBut​​tonStyleName样式设置为另一个样式选择器,该选择器包含按钮所需的所有样式。 You should be able to set the fillColors style of the buttons themselves there - this will change the default look of the button. 您应该能够在那里设置按钮本身的fillColors样式-这将更改按钮的默认外观。

If you need to adjust the "selected" color or if you need something more advanced than just skinning the button background you'll need to write a custom skin class. 如果您需要调整“选定”颜色,或者需要比仅给按钮背景蒙皮更高级的颜色,则需要编写一个自定义皮肤类。 This isn't too difficult - the Button class has a whole set of "Selected" styles - selectedDownSkin, selectedUpSkin, selectedDisabledSkin, etc. IMO the best practice is to set your button skin to a custom skin class that sets the different individual styles based on state. 这不太困难-Button类具有整套“ Selected”样式-selectedDownSkin,selectedUpSkin,selectedDisabledSkin等。IMO最佳做法是将按钮外观设置为自定义外观类,该类根据不同的个人风格进行设置在状态上。

David Flately illustrates this method here . David Flately 在这里说明了这种方法。 Check out his source - that should get you what you need. 查看他的消息来源-应该可以为您提供所需的东西。 A good book on this topic that has this sort of thing along with lots of other examples is Juan Sanchez and Andy McIntosh's Creating Visual Experiences with Flex 3.0. 关于这个主题的一本好书,其中包括此类内容以及许多其他示例,是Juan Sanchez和Andy McIntosh的“使用Flex 3.0创建视觉体验”。 I can't post a link to it because my reputation isn't high enough here yet, but you can find it on amazon or barnes and noble or any other online bookstore. 我无法发布链接,因为我的声誉在这里还不够高,但是您可以在亚马逊,巴恩斯,贵族或任何其他在线书店上找到它。

Haha, was looking for same thing, you can see on the source code of LinkBar: 哈哈,正在寻找相同的东西,您可以在LinkBar的源代码上看到:

    // Hilite the new selection.
    child = Button(getChildAt(selectedIndex));
    child.enabled = false;

Which is clever!!! 哪个是聪明的! Rather than set selected to true, they disable the selected button ... why not ;-( Took me half an hour to understand the Flex team logical ... 他们没有将selected按钮设置为true,而是禁用了selected按钮……为什么不这样做呢?-(花了我半个小时来了解Flex团队的逻辑...

eBuildy, Flex Specialists eBuildy,Flex专家

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM