On 2 Apr 2013, at 17:13, Mike Abdullah <cocoa...@mikeabdullah.net> wrote:
> > On 2 Apr 2013, at 12:43, jonat...@mugginsoft.com wrote: > >> I provide some app documentation in both RTF and MarkDown and switch in an >> NSTextView or WebView for display as required. >> >> But I don't see much in way of integrating NSTextFinder and WebView. The >> NSTextFinderClient protocol is quite extensive, which might explain why. >> >> Does anyone have any further insight into this? > > The problem is that Cocoa's Find Bar provides a whole raft of its own > functionality, not just a UI. It requires you to feed it a string, which it > will then search itself. There's no way (that I've come across) to have it > ask you to perform a search on its behalf. > > I believe the reason for this is that the Find Bar actually supports some > pretty complex, regular-expression-based searches, such as finding the URLs > in a given piece of text. > > WebKit does supply a decent bit of search functionality as it happens. It's > kinda hidden though — look up the WebDocumentSearching protocol! Yes. A single method, -searchFor:direction:caseSensitive:wrap: > > To make use of the find bar, I think you'd have to: > > A) Walk the DOM for text nodes to feed into NSTextFinder. Make sure to handle > whitespace the same way as WebKit renders it > B) Implement looking up a bit of such text from a given index. Likely some > sort of cache is needed to avoid walking the entire DOM every time for this > C) Watch for the DOM being modified as a cue to update the find system After posting I found https://github.com/Kapeli/HighlightedWebView which takes this approach. This could be paired with a custom find bar view to provide a decent solution. > > Also, file a radar asking for WebViews to support the Find Bar. Mine's > getting lonely! Your radar has a sibling @ 13558923 Thanks Jonathan _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com