Stacy,

 

I was having the same exact problem when my application loaded for the first time because I wanted the cursor to default and the caret be blinking in the username field of the login section so the user, when going to my site, didn’t have to explicitly click their mouse in the username field to login initially.  No matter what I tried, it didn’t work when I was going to http://localhost:7001/myapp/Index.mxml

 

BUT…I found a fix that has the caret blinking in my text field EVERY time without fail, which I don’t know if it’ll help with your situation or not, but what I did was I ended up embedding my application in a JSP page…so to access my application, the user now goes to http://localhost:7001/myapp/index.jsp and in my jsp page I have _javascript_ that EXPLICITLY sets focus to the now-embedded swf file…by doing this…the browser’s focus is initially set to the flash movie (i.e.: my flex app), which in turn successfully makes use of the Selection.setFocus(username) call successfully that I have in the creationComplete listener of the username TextInput component.

 

My index.jsp simply looks like this:

 

<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>

<%@ taglib uri="FlexTagLib" prefix="mm" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="ROBOTS" content="NOINDEX">

<title>My App</title>

<style type="text/css">

<!--

body {

          margin-left: 0px;

          margin-top: 0px;

          margin-right: 0px;

          margin-bottom: 0px;

}

-->

</style></head>

 

<body >

<mm:mxml source="Index.mxml" id="appSWF" name="appSWF" />

</body>

</html>

 

**Notice the onLoad listener of my <body> tag.

 

And then, in my Index.mxml file I simply have a view stack, whose first child is Login.mxml whose content looks like this:

 

<mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml"

          xmlns:merlinView="com.merlin.pb.view.*"

          title="Login"

                      width="772"

                      height="200"

                      horizontalAlign="left">

 

   <merlinView:LoginViewHelper name="loginView" view="{this}" />

 

   <mx:Script>

        <![CDATA[

                              import com.iterationtwo.cairngorm.control.EventBroadcaster;

         

                              public var statusMessage:String = "Please enter your username and password";

         

                              public function doLogin() {

                                        EventBroadcaster.getInstance().broadcastEvent("login");

                              }

                             

                              // check for enter key punch

                              function check(event) {

                                        var keyCode_num:Number = event.ascii;

                                        if (keyCode_num == Key.ENTER)

                                                  doLogin();

                              }

        ]]>

    </mx:Script>

         

          <mx:Text text="{ statusMessage }" width="100%" />

         

          <mx:VBox width="100%" height="100%" horizontalAlign="left">

 

                    <mx:Form id="loginForm">

                              <mx:FormItem label="Username: " horizontalAlign="left">

                                        <mx:TextInput id="username" creationComplete="Selection.setFocus(username);" />

                              </mx:FormItem>

         

                              <mx:FormItem label="Password: " horizontalAlign="left">

                                        <mx:TextInput id="password" password="true" keyDown="check(event);" />

                              </mx:FormItem>

                    </mx:Form>

                   

          </mx:VBox>

 

    <mx:ControlBar>

        <mx:Button label="Login" click="doLogin()" />

    </mx:ControlBar>

</mx:Panel>

 

Hope that helps,

 

Rob

 

Robert L. Brueckmann

Senior Web Developer

Merlin Securities, LLC

595 Madison Avenue

New York, NY 10022

p: 212.822.4821

f: 212.822.4820


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Stacy Young
Sent: Friday, July 15, 2005 1:02 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] onFocus, setSelection not highlighting textinput

 

Thanks for the effort Philippe but that also fails. (the first time)

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Philippe Maegerman
Sent: Friday, July 15, 2005 12:54 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] onFocus, setSelection not highlighting textinput

 

If you want the focus every time the current Viestack container is shown you can trigger the focus on the 'show' event of the container:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:LinkBar dataProvider="vs"></mx:LinkBar>
<mx:ViewStack id="vs">
<mx:HBox label="1"></mx:HBox>
<mx:HBox label="2" show="Selection.setFocus(myTI);"><mx:TextInput id="myTI"/></mx:HBox>
</mx:ViewStack>
</mx:Application>

 

Philippe Maegerman

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Philippe Maegerman
Sent: vendredi 15 juillet 2005 18:47
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] onFocus, setSelection not highlighting textinput

<mx:TextInput id="myTI" creationComplete="Selection.setFocus(myTI);"/>

 

Philippe Maegerman

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Stacy Young
Sent: vendredi 15 juillet 2005 18:11
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] onFocus, setSelection not highlighting textinput

Tried that too, no dice. :(

 

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Philippe Maegerman
Sent: Friday, July 15, 2005 12:07 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] onFocus, setSelection not highlighting textinput

 

maybe add creationComplete = "this.setFocus()" on the field itself

 

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Stacy Young
Sent: vendredi 15 juillet 2005 17:49
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] onFocus, setSelection not highlighting textinput

p.s. only occurs when displayed for the first time. (textinput sits in a viewstack). Tried changing the creationPolicy to all, no effect. When the viewstack is flipped back to show the field again later, the setFocus works as intended. Ack!

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Stacy Young
Sent: Friday, July 15, 2005 11:41 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] onFocus, setSelection not highlighting textinput

 

Minor annoyance here but I can’t seem to get the text of a textinput field to highlight properly. It’s as if the setFocus occurs before the textinput value is set so the cursor is just placed at index 0 of the field. Also tried explicitly selection the text in the field using setSelection but alas, no effect.

 

Myfield.text = “blah”;

Myfield.setFocus();  (or Selection.setFocus(Myfield))

 

Appreciate any insight,

Gracias,

Stace

 





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com


------------------------------------------------------------------
**STATEMENT OF CONFIDENTIALITY**

This e-mail and any attached files are confidential and intended solely for the use of the individual to whom it is addressed. If you have received this email in error please send it back to the person that sent it to you. Any views or opinions presented are solely those of author and do not necessarily represent those the Emakina Company. Unauthorized publication, use, dissemination, forwarding, printing or copying of this email and its associated attachments is strictly prohibited.

We also inform you that we have checked that this message does not contain any virus but we decline any responsability in case of any damage caused by an a non detected virus.
------------------------------------------------------------------



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com



 

This message contains information from Merlin Securities, LLC, or from one of its affiliates, that may be confidential and privileged. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify the sender immediately by telephone or by replying to this transmission.
 
Merlin Securities, LLC is a registered broker-dealer. Services offered through Merlin Securities, LLC are not insured by the FDIC or any other Federal Government Agency, are not deposits of or guaranteed by Merlin Securities, LLC and may lose value. Nothing in this communication shall constitute a solicitation or recommendation to buy or sell a particular security.


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to