12
Apr
08

Changing the focus rectangle color on a TextInput control in Flex

The following example shows how you can change the focus rectangle color for a Flex TextInput control by setting the themeColor style.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/04/12/changing-the-focus-rectangle-color-on-a-textinput-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import mx.events.DropdownEvent;
            import mx.events.ColorPickerEvent;

            private function colorPicker_change(evt:ColorPickerEvent):void {
                textInput.setStyle("themeColor", evt.color);
            }

            private function colorPicker_close(evt:DropdownEvent):void {
                focusManager.setFocus(textInput);
            }
        ]]>
    </mx:Script>

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="themeColor:">
                <mx:ColorPicker id="colorPicker"
                        change="colorPicker_change(event);"
                        close="colorPicker_close(event);" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:TextInput id="textInput" />

</mx:Application>

View source is enabled in the following example.


3 Responses to “Changing the focus rectangle color on a TextInput control in Flex”


  1. 1 eternalko Apr 13th, 2008 at 3:45 pm

    Good!

  2. 2 Rod Apr 14th, 2008 at 4:34 am

    This is the best Flex reference site ever! I wish I could tie in the Flex Builder dynamic help to this blog, lol.

    Thanks for your work.

  3. 3 FireWave Jul 17th, 2008 at 7:25 am

    Thx, I did’nt found the CSS entry.. I looked around “focus_” properties.

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".