开发者

Checkbox does not display properly in Flex

开发者 https://www.devze.com 2023-03-25 03:48 出处:网络
I have a checkbox that does not render as a checkbox and would be displayed as something similar to a button. However, it behaves like a checkbox where I can select it and the h开发者_运维技巧andlerwo

I have a checkbox that does not render as a checkbox and would be displayed as something similar to a button. However, it behaves like a checkbox where I can select it and the h开发者_运维技巧andler works with the firing event.

Here is my checkbox. I also tried it outside the or , but it has the same behavior. There is no CSS related to checkbox or the part that I am working on. I am using Flex 4.5 though.

1- Has anybody encounter such a problem?

2- Is there any way to enforce the layout inside a container and item renderer?

<mx:HBox>
    <mx:CheckBox id="Test"
        label="Label"
        fontWeight="bold"                                
                change="Test_changeHandler(event)"/>        
</mx:HBox>


If you're using Flex 4.5, why are you using Flex 3 components? Change this to spark components and everything should be much better:

<s:HGroup>
    <s:CheckBox id="Test"
        label="Label"
        fontWeight="bold"                                
                change="Test_changeHandler(event)"/>        
</s:HGroup>


mx:CheckBox extends mx:Button, so if you put added css that skinned mx:Button, mx:CheckBox would also get it. It's a shortcoming of flex 3 skinning. You can workaround by explicitly setting the mx:CheckBox skin.


Edit: try this

<mx:HBox>
    <mx:CheckBox id="Test"
        label="Label"
        fontWeight="bold"                                
        skin="{mx.skins.spark.CheckBoxSkin}"
        change="Test_changeHandler(event)"
        />        
</mx:HBox>


This happend to me also. Fix was to use a mx:Container as parent instead of FlexGlobals.application on the popup component.


for the second question:

I had exactly the same problem and i forced it to take the "original" skin with:

var skinClass:Class = mx.skins.spark.CheckBoxSkin;
theCheckBoxInstance.setStyle("skin", skinClass);

Because in my case the CheckBox was an ItemRenderer for a DataGrid, I've put it in the overridden createChildren methode right after the super call..

I have no explication why this happens. I encountered it in an old monster project where I was charged to make some changes...

0

精彩评论

暂无评论...
验证码 换一张
取 消