pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noel Grandin <noelgran...@gmail.com>
Subject Re: TextArea v. TextInput - Selection and Autocomplete
Date Thu, 06 May 2010 06:48:42 GMT
Hi David

TextArea treats the start of the selection area as the caret point. So
you can set the caret location by doing
   setSelection(index, 0);

Do you have some test-case code? A stripped down sample would make it
easier to debug this.

Regards, Noel Grandin

David McNelis wrote:
>
> Morning folks,
>
>  
>
> I have a set of information that I'm trying to auto-complete.  With a
> TextInput I didn't have any problems setting the 'result' and then
> highlighting the suggestion.  However, I am having trouble doing
> something similar in a TextArea.
>
>  
>
> Specifically if I find a valid result the following snippet is called
> for a TextInput:
>
>  
>
>                 String text = textInput.getText();
>
>                 String resultString = getCompletedString(text);
>
>                
>
> textInput.setText(resultString);
>
>  
>
> *int* selectionStart = text.length();
>
> *int* selectionLength = resultString.length() - selectionStart;
>
>  
>
> textInput.setSelection(selectionStart, selectionLength);
>
>  
>
>  
>
> The auto-complete functions as I'd want it in the TextInput just
> fine.  But when I port it to a TextArea the selection isn't processed
> in the same way.  I would just use a TextInput, however (and maybe I'm
> wrong), TextInput can't span multiple lines and the amount of text
> that might get tossed into the area is often too large to fit on a
> single line.  Also, I can't seem to set a specific index to set the
> cursor at in a TextArea either...looking at the methods available
> there is a TextArea.setCursor() method, but that doesn't take in an
> index at all.
>
>  
>
> Am I missing something simple?  Or am I trying to use a TextArea in a
> way that I shouldn't be?
>
>  
>
> Thanks for your thoughts,
>
> David
>


Mime
View raw message