We’ve run into the same thing.

There are two ways to accomplish the general goal in HTML. One is blur(). The 
second is to disable the focus rect.

Which one is better depends on accessibility concerns.

We never got around to encapsulating the functionality, so you need to do it 
manually. We used the button.element.blur() approach for buttons we did not 
want to have a focus rect.

Harbs

> On Nov 27, 2017, at 2:09 AM, Justin Mclean <[email protected]> wrote:
> 
> 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