You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Keith Mayfield <kr...@yahoo.com> on 2005/02/07 20:58:28 UTC

How do get the text that has been highligted

After a user has selected some text on the JSVGCanvas,
which api's would give me the text that has been
selected.  Some sample code would be great!!!

Thanx




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: How do get the text that has been highligted

Posted by Thomas DeWeese <Th...@Kodak.com>.
Thomas DeWeese wrote:
> Hi Keith,
> 
> Keith Mayfield wrote:
> 
>> After a user has selected some text on the JSVGCanvas,
>> which api's would give me the text that has been
>> selected.  Some sample code would be great!!!
> 
> 
>    Well the short answer is that it isn't that easy :/

    I just delivered an update to CVS.

    This is now much easier, you can now access the TextSelectionManager
from the JSVGCanavas.  This lets you do one of two things,
first you can register a selection listener and be notified as
the selection changes, or the SelectionManager has a 'getSelection'
method that returns the current selection (if any).


    canvas.getTextSelectionManager().getSelection();

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: How do get the text that has been highligted

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Keith,

Keith Mayfield wrote:

> After a user has selected some text on the JSVGCanvas,
> which api's would give me the text that has been
> selected.  Some sample code would be great!!!

    Well the short answer is that it isn't that easy :/

    Probably the easiest thing to do is give yourself
access to the TextSelectionManager in the JGVTComponent.
then give yourself access to the textSelector in the
TextSelectionManager, this would then allow you to
register a SelectionListener to the canvas (this should
probably be exposed on the canvas).

    The selectionListener gets called with a SelectionEvent
from which you can get the current Selection Object.  I
think this is currently an AttributedCharacterIterator
but you can get just a string from that if you want.



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org