Well I thought it was a question of timing so I tried doLater() and 
setInterval(), and it wasn't working.  
When tracing the text length in the second function called by doLater, it was 
showing the right value, grrrrr!! 
Then I tried with static text "23." in the field and setSelection(0,3) and that 
was working, so I guessed it was just the component not redrawing fast enough, 
then I tried redraw(), and voilàààà
redraw() has saved me a few times already in datagrid and others, sometimes 
invalidate() do the job too.

Philippe Maegerman

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Niklas 
Richardson
Sent: mercredi 10 août 2005 15:49
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Caret positioning problem

Yeah, I just found that if you split the two commands into separate functions, 
and associate them with the click event on two bottons. 
Then pressing the first button (to add the dot) and then pressing the second 
button (to select the end of the string), then it works.

Nice find on the redraw().  What made you think of that?

If you set the first number in setSelection() then it will just give you a 
single caret rather than selection the whole text.  Like Allen suggested 
earlier.  This is the code I used to get it working (using your redraw() trick 
Philippe).  You don't need to use the FocusManager then either (okay, so you 
only save one line!!!!).

myText.text = myText.text + '.';
myText.redraw();
Selection.setFocus("myText");
Selection.setSelection(myText.text.length, myText.text.length);

Cheers

Niklas



On 10/08/05, Philippe Maegerman <[EMAIL PROTECTED]> wrote:
>  
> Don't ask me how I found it, I tried all kind of things like 
> setInterval, doLater etc ...
>   
> MyTextField.text = MyTextField.text + "."; MyTextField.redraw(); var 
> fm = getFocusManager(); fm.setFocus(MyTextField);
> Selection.setSelection(0,MyTextField.text.length)
>   
> Enjoy++ 
>   
> Philippe Maegerman
> Web developer
> +32 2 400 40 39
> +32 472 35 28 10
> Avoir des rêves, c'est continuer d'exister... 
>  
>  
>  ________________________________
>  From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
> On Behalf Of Mika Kiljunen
> Sent: mercredi 10 août 2005 15:27
> 
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Caret positioning problem
> 
>  
>  
>  
> 
> You wish...but  no, does not work (already tried it) L
> 
>   
> 
> -Mika
> 
>   
>  
>  ________________________________
>  
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
> On Behalf Of Philippe Maegerman
> Sent: 10. elokuuta 2005 16:16
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Caret positioning problem
> 
>   
> 
> MyTextField.text.length+1 maybe ;)
> 
>   
> 
> Philippe Maegerman
>  
>  ________________________________
>  
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
> On Behalf Of Mika Kiljunen
> Sent: mercredi 10 août 2005 14:47
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Caret positioning problem
> 
> Thanks, but it won't help. If I type in "23" my handler adds a dot to 
> it and the text becomes "23."
> 
> Your code sets the "23" selected and caret is there (not after the 
> added dot as it should be), the thing is that it should show 23. and 
> caret after that, and no selection.
> 
>   
> 
> -Mika
> 
>   
>  
>  ________________________________
>  
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
> On Behalf Of Philippe Maegerman
> Sent: 10. elokuuta 2005 15:35
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Caret positioning problem
> 
>   
> 
> var fm = getFocusManager();
> fm.setFocus(MyTextField);
> Selection.setSelection(0,MyTextField.text.length)
>  
> 
> Philippe Maegerman
> 
>   
>  ________________________________
>  
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
> On Behalf Of Allen Manning
> Sent: mercredi 10 août 2005 14:32
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] Caret positioning problem
> 
> Mika,
> 
>   
> 
> Have you looked at: 
> 
>   
> 
> Selection.setSelection(stringLength,stringLength)
> 
>   
> 
>   
> 
> HTH,
> 
> Allen
> 
> www.prismix.com/
> 
>   
>  
>  ________________________________
>  
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
> On Behalf Of Mika Kiljunen
> Sent: 10 August 2005 13:25
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Caret positioning problem
> 
>   
> 
> Hi,
> 
> I'm trying to set the caret to the end of the textfield. I have a 
> keyUp event handler that adds the dot "." automatically for the text 
> entered. The problem is that when the dot is added by actionscript the 
> caret stays behind the added dot while typing, so the dot gets 
> misplaced and the typing comes out wrong. How can I position the caret 
> AFTER the autoinserted dot? I've tried to fool around with the 
> Selection class functions but none of it seems to help..
> 
>   
> 
> Here is an example of the handler I'd like to use: 
> 
>   
> 
> function onKeyUp( event )
> 
>             {
> 
>             if( MyTextField.text.length == 2 )
> 
>                         {                       
> 
>                         MyTextField.text = MyTextField.text + ".";
> 
>                         // HOW TO POSITION THE CARET HERE SO THAT IT 
> COMES OUT LIKE THIS ON TEXTFIELD:
> "myenteredtext.CARET_BLINKING_HERE??? 
> 
>                         }
> 
>             }
> 
>   
> 
> -Mika
> 
>   
> 
> 
> 
>  
> 
> ------------------------------------------------------------------
> **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
> 
>  
> 
>  
>  SPONSORED LINKS
>  Computer software testing Macromedia flex Development  Software 
> developer
>  
>  ________________________________
>  YAHOO! GROUPS LINKS
>  
>  
>  Visit your group "flexcoders" on the web.
>   
>  To unsubscribe from this group, send an email to:
>  [EMAIL PROTECTED]
>   
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
>  
>  ________________________________
>  


--
Niklas Richardson
Prismix Ltd

Flex and ColdFusion Experts!


------------------------ Yahoo! Groups Sponsor --------------------~--> <font 
face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hn61cft/M=362329.6886308.7839368.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123688967/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font> 
--------------------------------------------------------------------~-> 

--
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



 


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hn0sjc6/M=362335.6886445.7839731.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123689423/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/";>In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~-> 

--
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

<*> 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