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. > Text view searching works well using the NSTextFinder find bar. > However, implementing a WebView find panel/bar seems difficult. > > - (void)performFindPanelAction:(id)sender is still not implemented - ref: > https://bugs.webkit.org/show_bug.cgi?id=3640 > Current WebKit source still documents this as unimplemented - ref: > https://trac.webkit.org/browser/trunk/Source/WebKit/mac/WebView/WebHTMLView.mm > > Some swizzling however can be effective - ref : > http://www.taffysoft.com/pages/20120908-01.html > So this can be investigated. > > 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! You could provide your own UI atop that. 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 Also, file a radar asking for WebViews to support the Find Bar. Mine's getting lonely! _______________________________________________ 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