Return-Path: Delivered-To: apmail-pivot-user-archive@www.apache.org Received: (qmail 49933 invoked from network); 6 May 2010 06:49:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 May 2010 06:49:15 -0000 Received: (qmail 36203 invoked by uid 500); 6 May 2010 06:49:15 -0000 Delivered-To: apmail-pivot-user-archive@pivot.apache.org Received: (qmail 36144 invoked by uid 500); 6 May 2010 06:49:14 -0000 Mailing-List: contact user-help@pivot.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@pivot.apache.org Delivered-To: mailing list user@pivot.apache.org Received: (qmail 36136 invoked by uid 99); 6 May 2010 06:49:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 06:49:14 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of noelgrandin@gmail.com designates 74.125.82.54 as permitted sender) Received: from [74.125.82.54] (HELO mail-ww0-f54.google.com) (74.125.82.54) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 06:49:05 +0000 Received: by wwb34 with SMTP id 34so444885wwb.13 for ; Wed, 05 May 2010 23:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type; bh=r9NOhrKUKO87DRGbvuIdszt4+ZuiFA8guQH/F2r029s=; b=T1O8Y3/mCedE6J2Fsgbvse1fM/RtEeX571fqBLRHfbHDYpcCNiFfJWE53/95yRfPwX LKRz6V+vWsJ6zrpKFFeGGfWHNoJnUmjCzJ6BbNiXkhRaVrhmL55OvbC1TtFag2k1QwIX ZdVki+Fr4p+Qqq4paI56OxcOxfIBxIoT15G9I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=h6+JY3JwTWR63k5gV5yg3p6gRMuJYkjYzsb0YmHqKVx9vjeGJf+HeirLCMNdL8s4i8 on5FPjDnlFYTaD8lBGIIGNYpupWLFFAjAHFt9S1FtIVumeiEM8f8IE/ZHYGEkBdgOzbc ktBYIKUmcTwKm32fFXfH31Xf91fx5fsHKNXy8= Received: by 10.227.137.67 with SMTP id v3mr3684893wbt.92.1273128524663; Wed, 05 May 2010 23:48:44 -0700 (PDT) Received: from [192.168.1.71] (uni-227-242.uninet.co.za [41.207.227.242]) by mx.google.com with ESMTPS id z33sm5025024wbd.19.2010.05.05.23.48.40 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 05 May 2010 23:48:43 -0700 (PDT) Message-ID: <4BE2664A.9080206@gmail.com> Date: Thu, 06 May 2010 08:48:42 +0200 From: Noel Grandin User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8) Gecko/20051201 Thunderbird/1.5 Mnenhy/0.7.3.0 MIME-Version: 1.0 To: user@pivot.apache.org CC: David McNelis Subject: Re: TextArea v. TextInput - Selection and Autocomplete References: <2701CF596B80DC44815FDBFFF5881A1EA2800F@exchange01.sharedmarketing.com> In-Reply-To: <2701CF596B80DC44815FDBFFF5881A1EA2800F@exchange01.sharedmarketing.com> Content-Type: multipart/alternative; boundary="------------000803020107000709010603" X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. --------------000803020107000709010603 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 > --------------000803020107000709010603 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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


--------------000803020107000709010603--