Hi,

Is there any focus/unfocus API for buttons?

Currently I have a small issue where I need to unfocus a button after the 
button text changes. 

Here some code to illustrate the issue:

<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
                xmlns:js="library://ns.apache.org/royale/basic">

    <fx:Script><![CDATA[
        public function changeText():void {
            button.text = "Clicked";
            // TODO unfocus the button
        }
        ]]></fx:Script>

    <js:valuesImpl>
        <js:SimpleCSSValuesImpl/>
    </js:valuesImpl>
    
    <js:initialView>
        <js:View percentWidth="100" percentHeight="100">
            <js:HContainer>
                <js:TextButton id="button" text="Click Me!" 
click="changeText()"  />
                <js:TextButton text="Ordinary Button" />
            </js:HContainer>
        </js:View>
    </js:initialView>

</js:Application>

About the only way of doing it that I can think of is:

public function changeText():void {
    button.text = "Clicked";
    COMPILE::JS {
        button.element.blur();
    }
    COMPILE::SWF {
        stage.focus = null;
    }
}


But in general it useful to be able to set and unset the focus in a set buttons.

Is there a better way to do this? And if not should there be an API in the 
framework to do this?

Thanks,
Justin

Reply via email to