The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > Omni Frameworks
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Link Detection on OUIEditableFrame Thread Tools Search this Thread Display Modes
Morning everyone; I've been struggling with the OmniUI framework and was finally able to add it to my project; right now everything is working perfectly except for the link detection.

The "Text Editor" displays the URLs with the underline and the blue color but the links are not "detected". I'm trying to modify the code to detect them but to no avail.

Does anybody has an idea if this is possible and if so how to do it?

Thanks in advance.
 
We use our own link detection in OmniOutliner, but it should be possible to hook in Apple's (and we may switch to it later).

See NSRegularExpression.h, specifically -[NSDataDetector initWithTypes:error:] and related APIs.

Fully adopting data detectors will be a bunch of work to get right and to make it perform well, but it could provide some nice features (text replacement, smart quotes, links and such).
__________________
CTO, The Omni Group
 
Thanks for the reply Tim, perhaps you might give be an easier solution.
All I need to do is display the text formatted (reading it from a web service) I don't need to provide editable capabilities; I decided to use the "TextEditor" example because it was working and displaying the RTF format.

On the downside one of my requirements is that I provide working links within the text.

Using the TextEditor example and modifying it to match my needs would be the best approach or you guys have some other component that might help me accomplish this easier?

PS. Its an iPad project btw.

Thanks,
 
Starting from the TextEditor sample would work, though depending on the format of the text from a web service, using UIWebView might be easier.

If you are able to find links in the text w/o using data detectors, you can apply a OALinkAttributeName attribute with a NSURL value to the applicable range of the NSAttributedString you hand over to OUIEditableFrame. Of course, if you are doing this, you may also find it is easier to fetch the results from your web service and internally convert them to HTML and use a UIWebView. OUIEditableFrame may not be the right tool for the job, though it probably can be made to do it.
__________________
CTO, The Omni Group
 
Thanks for the reply Tim; I'm trying to stay away from the webview for this mainly because I have to display formatted text on a table view; which would meant "multiple" webviews per table (one for each cell) and I think that would be too much overhead.

I tried with RTF parser that comes with the OmniUI project but I'm unable to recognize the hyperlinks because I think they are treated as "normal" text.
I'll keep trying to add this functionality otherwise I'll have to figure out another way.

Thanks for your replies.

PS. do you happen to know how I could possibly detect hyperlinks with the RTF parser?
 
Quote:
Originally Posted by Creegan View Post
PS. do you happen to know how I could possibly detect hyperlinks with the RTF parser?
We don't currently deal with hyperlinks in OUIRTFReader/OUIRTFWriter since we don't yet need them, but you can see what the markup looks like if you'd like to: make a RTF file with a link in Text Edit (select some text and hit cmd-k to add a link), you'll see something like:

Quote:
{\field{\*\fldinst{HYPERLINK "http://www.apple.com"}}{\fldrslt test link}}
__________________
CTO, The Omni Group
 
Dear Tim,

from a brief look at the code I see that currently, the OALinkAttributeName is merely used to create the appearance of a link by converting attributes using some custom formatting.

Some brief questions in preparation of implementing some basic link handling myself:

- Are the actual OALinkAttributeName attributes kept? I see they are only removed in OUITextLayoutCopyExtraNewlineAttributes

- Do you have any hints on where to start to implement basic link handling?

My first idea would be to check for the link attributes in the "_activeTap:" method and extend the delegate protocol.

Thanks a lot,
-David.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
OUIEditableFrame truncating? tommetge Omni Frameworks 1 2010-12-26 07:41 AM
Scrolling an OUIEditableFrame tommetge Omni Frameworks 1 2010-08-07 12:01 PM
OUIEditableFrame dependencies tommetge Omni Frameworks 2 2010-08-06 08:28 AM
RSS Feed Title Detection hardcoreUFO OmniWeb Feature Requests 0 2008-02-06 11:22 AM
5.7[96513] Some browser detection problem on songbird website marlwin OmniWeb Bug Reports 0 2007-12-29 04:54 PM


All times are GMT -8. The time now is 02:24 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.