Changing the background color of a disabled Flex TextInput control

by Peter deHaan on October 10, 2007

in TextInput

The following example shows how you can use the backgroundDisabledColor style to customize the overlay color on a Flex TextInput control when the control’s enabled property is set to false.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/10/10/changing-the-background-color-of-a-disabled-flex-textinput-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:ApplicationControlBar dock="true">
        <mx:Label text="backgroundDisabledColor:" />
        <mx:ColorPicker id="colorPicker"
                selectedColor="white" />

        <mx:CheckBox id="checkBox"
                label="enabled:"
                labelPlacement="left" />
    </mx:ApplicationControlBar>

    <mx:TextInput text="The quick brown fox"
            backgroundDisabledColor="{colorPicker.selectedColor}"
            enabled="{checkBox.selected}" />

</mx:Application>

View source is enabled in the following example.

{ 5 comments… read them below or add one }

1 coco October 11, 2007 at 9:28 pm

peter,
Now i have a question:when i save my project,it will take me more time to finish it!at first time,it takes several seconds ,now it takes about 1 min! why does this status happen?how to solve this problem?
coco

Reply

2 peterd October 12, 2007 at 8:00 am

coco,

Try cleaning your project in Flex Builder using the Project > Clean menu command, and see if that helps.
Also, are you using Flex Builder 2 or Flex Builder 3 Beta (and if FB3, are you using Beta 1 or Beta 2?)

Peter

Reply

3 coco October 14, 2007 at 6:10 pm

peter,

It’s usefull!Thanks!I am now using FB2!
coco

Reply

4 Reiner October 9, 2009 at 9:37 am

//Declare a variable
[Bindable]
public var myborderColor: ColorPicker = new ColorPicker();

//
private function init():void
{
myborderColor:.selectedColor = Color.WHITE ;

… …. in other function change the color
myborderColor:.selectedColor = Color.RED ;

Reply

5 Reiner October 9, 2009 at 9:39 am

//Declare a variable
[Bindable]
public var myborderColor: ColorPicker = new ColorPicker();

private function init():void
{
myborderColor:.selectedColor = Color.WHITE ;

… …. in other function change the color
myborderColor:.selectedColor = Color.RED ;

… mx:TextInput id=”myText” backgroundColor=”{numcasoborderColor.selectedColor}” …

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: