Focus Not Automatically Set To The PopUp Window

Focus Not Automatically Set To The PopUp Window

When you create a modal PopUp window by clicking a button, the focus is still left on the button you clicked to instantiate the PopUp. Even if you can’t click the button with your mouse because of the modal window, you will still be able to press the space bar to “click” that button causing more PopUp windows to be instantiated. To change this behavior, you can remove the focus from the button by setting the stage’s focus to null in the PopUp window component’s addedToStage or creationComplete event:

creationComplete=”stage.focus=null;”

or

addedToStage=”stage.focus=null;”

A better way to handle this is to set the focus to the PopUp window’s close button if it has one. Set the close button as the default button and call the button’s setFocus() method. You should do this only in the creationComplete event of your PopUp window component, calling it in the addedToStage event won’t work:

creationComplete=”defaultButton = btnClose; btnClose.setFocus();”

2 Responses to “Focus Not Automatically Set To The PopUp Window”


  1. 1 mars76 September 25, 2007 at 10:00 pm

    Hi,

    If i am popping up more than one Title window . How can i chage the focus from One Window to another programatically ??

    Thanks
    Mars

  2. 2 ricoz September 26, 2007 at 1:09 pm

    Mars,

    You can call the title window’s setFocus() method. If you called setFocus() in the creationComplete event, then the most recently instantiated title window will receive the focus.

    Rico


Leave a Reply

You must login to post a comment.