pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: TextArea v. TextInput - Selection and Autocomplete
Date Thu, 06 May 2010 11:25:27 GMT
The selection logic should work the same for TextArea as it does for TextInput. Not sure what
the problem might be.

Re: cursor - do you mean "cursor" or "caret"? Cursor generally refers to the mouse pointer,
whereas caret refers to the blinking line representing the insertion point for text. setCursor()
controls the cursor style - calling setSelection() with a selection length of 0 positions
the caret.

On May 5, 2010, at 10:00 AM, 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
> Thanks for your thoughts,
> David

View raw message