Hi Ajay,
        There are two methods in TextArea that could be used:
setSelection(int selectionStart, int selectionLength); or
setSelection(Span selection);
        If you already know the offset and length of where you want to
select, then you can use the first one:
... in your ButtonPressListener ...
                int start = <starting offset of text to select>;
                int length = <length of text>;
                textArea.clearSelection();
                textArea.setSelection(start, length);

        Alternatively, you can use the methods that involve a Span
object:
                Span span = new Span(start, end);
                textArea.setSelection(span);

HTH,
~Roger Whitcomb

-----Original Message-----
From: Ajay Bhat [mailto:a.ajay.b...@gmail.com] 
Sent: Wednesday, July 17, 2013 11:44 AM
To: dev@pivot.apache.org
Subject: How to highlight text using Pivot?

Hi,

I'm using Pivot API for GUI application. I'd like to know how I can
display some text in a text area being highlighted, by basically being
selected when I use a ActionListener.

Eg: Entered text is:

The quick brown fox jumps over the lazy dog.

And I want to highlight the word 'quick' in the text area by having it
selected on clicking some button. How do I do it?

Thanks,
Ajay

Reply via email to