JC KODEL:

achei a funçao aqui para selecionar a ultima posicao:

FICOU ASSIM:
protected function textInput_keyUpHandler(event:KeyboardEvent):void {
//188 = virgula
    if (event.keyCode == 188) {
        var ti:String = textInput.text;
        ti = ti.substr(0, textInput.selectionAnchorPosition) + "." +
             ti.substr(textInput.selectionAnchorPosition +
textInput.selectionAnchorPosition + 1);
        textInput.text = ti ;
        textInput.selectRange(ti.length,ti.length);
    }
}

Muito obrigado pela ajuda.


On 21 dez, 09:02, samuelfac <samuel...@gmail.com> wrote:
> J.C.Kodel :
> tentei assim:
> protected function textInput_keyUpHandler(event:KeyboardEvent):void {
> //188 = virgula
>     if (event.keyCode == 188) {
>         var ti:String = textInput.text;
>         ti = ti.substr(0, textInput.selectionAnchorPosition) + "." +
>              ti.substr(textInput.selectionAnchorPosition +
> textInput.selectionAnchorPosition + 1);
>         textInput.text = ti ;
>     }
>
> }
>
> mas como faço para posicionar o cursor na ultima posiçao?? pois essas
> propriedades se selecion sao todas READ-ONY...
> alguma dica??
>
> Obrigado.
>
> On 18 dez, 17:47, J.C.Ködel <jcko...@gmail.com> wrote:
>
> > Tente o seguinte:
>
> > 1) Remova a vírgula das restrições (ou seja, restrinja apenas 0-9. (ponto))
> > 2) No evento KeyPress ou KeyDown do textInput, verifique se a tecla
> > pressionada é vírgula
> > 3) Caso seja, faça o seguinte:
>
> > var ti:String = textInput.text;
>
> > ti = ti.substr(0, textInput.selectionStart) + "." +
> > ti.substr(textInput.selectionStart + textInput.selectionLength + 1)
> > textInput.text = ti
>
> > (não tenho certeza quanto ao nome da propriedade selection start e length,
> > dá um look na documentação).
>
> > O que isso faz?
>
> > Quando eu pressionar a tecla vírgula, ele insere um ponto na posição atual
> > do cursor (que é definido por selectionStart).
>
> > --------------------------------------------------
> > From: "samuelfac" <samuel...@gmail.com>
> > Sent: Friday, December 18, 2009 5:40 PM
> > To: "flexdev" <flexdev@googlegroups.com>
> > Subject: [flexdev] Re: Trocar virgula por ponto ao digitar
>
> > > alguem???
>
> > > On 17 dez, 12:51, samuelfac <samuel...@gmail.com> wrote:
> > >> Obrigado pelas respostas, mas nao posso fazer join ou replace, pois eh
> > >> um textInput, e a variavel de moeda, eh Number...
>
> > >> ex:
> > >> <s:TextInput id="txtInput"
> > >>     change="{controller.changeValor(parseFloat(txtInput.text))}"
> > >>     restrict="0-9.,"/>
>
> > >> tentei colocar o replace assim:
> > >> <s:TextInput id="txtInput"
> > >>     change="{controller.changeValor(parseFloat(txtInput.text.replace
> > >> (',','.')))}"
> > >>     restrict="0-9.,"/>
>
> > >> mas da muito problema assim...
>
> > >> o q eu gostaria mesmo, seria uma funçao por exemplo:
>
> > >> keyDown - ao precionar a verigula, o valor retornado eh o Ponto...
> > >> mas nao sei como fazer.
>
> > >> Muito Obrigado.
>
> > >> On 16 dez, 20:28, Douglas Guimarães de Freitas <hay...@gmail.com>
> > >> wrote:
>
> > >> > faz com split e join ou procura por expressao regular..
>
> > >> > 2009/12/16 RafaelViana <rfl.vi...@gmail.com>
>
> > >> > > No evento change do textinput, você verifica se tem vírgula e faz um
> > >> > > replace por ponto?
>
> > >> > > On 16 dez, 17:42, samuelfac <samuel...@gmail.com> wrote:
> > >> > > > Olá pessoal.
>
> > >> > > > Em um textinput, quero digitar valores de moeda (R$), e fiz uma
> > >> > > > limitaçao de caracteres assim: restrict="0-9."
>
> > >> > > > neste caso nao permito a digitaçao de virgula,
> > >> > > > mas aih vem onde eu quero chegar...
>
> > >> > > > como faço para no momento em que a pessoa precionar a vrgula, seja
> > >> > > > retornado um ponto???
>
> > >> > > > *PS: nao gostaria de usar componentes externos.
>
> > >> > > > Muito Obrigado.
>
> > >> > > --
> > >> > > Você recebeu esta mensagem porque está inscrito na lista "flexdev"
> > >> > > Para enviar uma mensagem, envie um e-mail para
> > >> > > flexdev@googlegroups.com
> > >> > > Para sair da lista, envie um email em branco para
> > >> > > flexdev-unsubscr...@googlegroups.com
> > >> > > Mais opções estão disponíveis
> > >> > > emhttp://groups.google.com/group/flexdev
>
> > >> > --
> > >> > Douglas G. de Freitas
>
> > > --
> > > Você recebeu esta mensagem porque está inscrito na lista "flexdev"
> > > Para enviar uma mensagem, envie um e-mail para flexdev@googlegroups.com
> > > Para sair da lista, envie um email em branco para
> > > flexdev-unsubscr...@googlegroups.com
> > > Mais opções estão disponíveis emhttp://groups.google.com/group/flexdev
>
> >  smime.p7s
> > 6KExibirDownload
>
>

-- 
Você recebeu esta mensagem porque está inscrito na lista "flexdev"
Para enviar uma mensagem, envie um e-mail para flexdev@googlegroups.com
Para sair da lista, envie um email em branco para 
flexdev-unsubscr...@googlegroups.com
Mais opções estão disponíveis em http://groups.google.com/group/flexdev

Responder a