Hi Devis,

You need to click on Flex app once(anywhere) to set focus on entire Flex
app. By default, browser doesn't set focus to Flex/Flash app on load.

But in Internet Explorer, you can use some javascript to set focus to
Flex/Flash application. But you need to do use some javascript.

Calling flashObject.focus() would set the focus to flashObject in browser.
Where flashObject is reference to Flash ActiveX in IE.

There are two ways to do this:

1) Write a custom HTML wrapper page for your flex application or customize
default html wrapper, you need to be careful for history management related
JS code.
2) Use JSP page

I have written the following jsp code, using jsp has advantage that
javascript code generated by flex server would still be there...


<<%@ taglib uri="FlexTagLib" prefix="mm" %>
<HTML>
<HEAD>
<meta http-equiv=Content-Type content="text/html;  charset=ISO-8859-1">
<TITLE>Flex-Focus Demo</TITLE>

</HEAD>
<BODY bgcolor="#FFFFFF" onload="flexApp.focus();">

<!-- look at "flexApp" id/name, thats being used(in JS) to get the reference
of Flash Player in browser. -->

<mm:mxml border="1" id="flexApp" name="flexApp">

    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
       themeColor="haloSilver"
       backgroundColor="#FFFFFF"
       xmlns="*"
       creationComplete="initShop();">
      
           <mx:Script>
            
             function initShop():Void
             {
               tx_bar.setFocus();
             }
            
           </mx:Script>
          
            <mx:HBox width="100%" height="100%">
        
                <mx:VBox width="30%" height="100%" id="barcode">
                    <mx:Panel title="Barcode" width="100%" height="10%">
                    <mx:Label text="Barcode"/>
                    <mx:TextInput id="tx_bar"/>
                    </mx:Panel>
        
                   
                </mx:VBox>
        
           <mx:VBox width="100%" height="100%">
              <mx:Panel title="Status Registratore" width="100%"
height="25%" 
        click="initShop()"/>
             
        
         </mx:VBox>
         </mx:HBox>
    </mx:Application>
</mm:mxml>

</BODY>

</HTML>


Hope that helps...

-abdul

 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 18, 2005 9:39 PM
To: [email protected]
Subject: Re: [flexcoders] Stupid Question


Hi Abdul,
it's very strange i have put creatationComplete as below,
but don't work, the TextInput  border became "bold"  but if i'm writing 
the TextInput don't work.
Any idea?
Devis

Abdul Qabiz ha scritto:

>Hi,
>
>Call the initShop() function in creationComplete handler of Application
like
>this...
>
>##changedCode##
>
><?xml version="1.0" encoding="utf-8"?>
>
><mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
>   themeColor="haloSilver"
>   backgroundColor="#FFFFFF"
>   xmlns="*"
>   creationComplete="initShop();">
>  
>   <mx:Script>
>    
>     function initShop():Void
>     {
>       tx_bar.setFocus();
>     }
>    
>   </mx:Script>
>  
>    <mx:HBox width="100%" height="100%">
>
>        <mx:VBox width="30%" height="100%" id="barcode">
>            <mx:Panel title="Barcode" width="100%" height="10%">
>            <mx:Label text="Barcode"/>
>            <mx:TextInput id="tx_bar"/>
>            </mx:Panel>
>           
>            <Resi/>
>            <Abbuoni />
>           
>        </mx:VBox>
>
>   <mx:VBox width="100%" height="100%">
>      <mx:Panel title="Status Registratore" width="100%" height="25%" 
>click="initShop()"/>
>      <Dettaglio/>
>      <Carrello/>
>     
>
> </mx:VBox>
> </mx:HBox>
> 
></mx:Application>  
>
>
>-abdul
>  
>  
>
>-----Original Message-----
>From: [email protected] [mailto:[EMAIL PROTECTED] 
>Sent: Monday, April 18, 2005 8:34 PM
>To: Flex Coders
>Subject: [flexcoders] Stupid Question
>
>
>Sorry, can you help me?
>how i can  do  that my tx_bar have the focus when application will be init?
>Devis
>
>
> <?xml version="1.0" encoding="utf-8"?>
>
><mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
>   themeColor="haloSilver"
>   backgroundColor="#FFFFFF"
>   xmlns="*"
>   initialize="initShop();">
>  
>   <mx:Script>
>    
>     function initShop():Void
>     {
>       tx_bar.setFocus();
>     }
>    
>   </mx:Script>
>  
>    <mx:HBox width="100%" height="100%">
>
>        <mx:VBox width="30%" height="100%" id="barcode">
>            <mx:Panel title="Barcode" width="100%" height="10%">
>            <mx:Label text="Barcode"/>
>            <mx:TextInput id="tx_bar"/>
>            </mx:Panel>
>           
>            <Resi/>
>            <Abbuoni />
>           
>        </mx:VBox>
>
>   <mx:VBox width="100%" height="100%">
>      <mx:Panel title="Status Registratore" width="100%" height="25%" 
>click="initShop()"/>
>      <Dettaglio/>
>      <Carrello/>
>     
>
> 
> </mx:VBox>
> 
> 
> </mx:HBox>
>
>
> 
>  
></mx:Application>  
>  
>  
>
>
>
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>  
>




 
Yahoo! Groups Links



 





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to