开发者

Component isn't visible on the form

开发者 https://www.devze.com 2023-03-24 13:23 出处:网络
I made a very simple component to replace any component (e.g. a comboBox) on a form that is hidden if a user does not have access to change the value:

I made a very simple component to replace any component (e.g. a comboBox) on a form that is hidden if a user does not have access to change the value:

<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml"
          visible="{!_controlToReplace.visible}"
          includeInLayout="{!_controlToReplace.includeInLayout}">
    <mx:Script>
        <![CDATA[
            import mx.core.UIComponent;
            [Bindable]
            private var _controlToReplace:UIComponent;

            public function set controlToReplace(value:UIComponent):void
            {
                _controlToReplace=value;
            }
        ]]>
    </mx:Script>
</mx:Label>
开发者_运维知识库

The same functionality of the component can be easily done by having a label on the form instead:

<mx:Label text="{objControl.text}"
visible="{!objControl.visible}"
includeInLayout="{!objControl.includeInLayout}"/>

With the component I can do this, which I like better:

<Components:ReadOnlyPlaceHolder controlToReplace="{objControl}"/>

But regardless of whether or not objControl is visible, it doesn't get displayed. Do you have any idea what I could be missing?


I believe the problem is that binding is not updating the properties on the label. Instead of using binding, just update them manually, ike this:

public function set controlToReplace(value:UIComponent):void
{
    _controlToReplace=value;
    visible = !_controlToReplace.visible;
    includeInLayout = !_controlToReplace.includeInLayout;
}

If that doesn't work, you'll have to show us your form and the layout code that positions and displays your ReadOnlyPlaceHolder.

0

精彩评论

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