Skip to main content
January 12, 2011
Question

Link creation while typing

  • January 12, 2011
  • 1 reply
  • 544 views

Hi,

I am using TLF TextFlow as rich text editor. The editor is capable of detecting the hyperlink & convert it into actionable link. Iam trying with adding event:

CompositionCompleteEvent.COMPOSITION_COMPLETE exporting text then using regular expression reform the html text and finally importing again. But I think that seems to be very costly in terms of performance.

Can anybody help me out if I am going wrong?

One more doubt: Is there any way to assign new text in TextLayoutFormat?

Thanks in advance.

Gaurav

This topic has been closed for replies.

1 reply

Adobe Employee
January 12, 2011

I am not quite sure what you are asking, so I hope this answers your question. The standard way to add a hyperlink in a TextFlow is to use the EditManager in the TextFlow's interactionManager. It has a method, applyLink, that takes the current selection and makes it into a hyperlink.This is *much* more efficient than exporting, editing the html or xml, and reimporting.

Likewise, if you want to insert new text, and assign formatting properties to the new text, then you can use the interactionManager. It has a method, insertText, that inserts the text. To apply the formatting properties, you can either do that as a second call to the EditManager's applyFormat, or you can suppy a SelectionState when you call insertText that contains the properties you would like applied in the SelectionState's pointFormat property.

Hope this helps,

- robin

January 13, 2011

Hi Robin,

Thanks.

What I mean to creat link while typing is suppose I am typing "The url of Adobe Systems is www.adobe.com". Then www.adobe.com should automatically convert into actionable link(using regular expression). I am not doing like selecting something & then through pop up asking for the url.

Let me know, is there any way to achieve this type of link creation?

Thanks in advance.

Adobe Employee
January 13, 2011

Now I understand. I would suggest attaching a listener for the FLOW_OPERATION_END event, checking for events that can change the content (e.g., text insertion, deletion, pasting). The operation inside the event will tell you what was being done, and it will also show the range of affected text. You will need to have code that examines this range of text in the TextFlow (if necessary you can call getText to get it in String form), and if it detects a link then calls back into the EditManager's applyLink method to create a new link.

We have some example code that shows adding event listeners like that, or if you are using Flex (see the TLF Blog), or you can look into the Flex code which also is attaching listeners of this type for an example of what this would look like.

Thanks,

- robin