WebView in Safari 1.3 and later is documented to implement performFindPanelAction:, but the actual implementation just consists of - (void)performFindPanelAction:(id)sender { // Implementing this will probably require copying all of NSFindPanel.h and .m. // We need *almost* the same thing as AppKit, but not quite. ERROR("unimplemented"); } This is the same as rdar://4109997
confirmed.
If there's any reasonable way of implementing this without access to the AppKit source (NSFindPanel.h and .m, as mentioned in the comment), then I would be happy to look into writing a patch for it.
I'd like to offer 100 Euros to any person who implements the feature, i.e. the ability to search within a WebKit view with the normal Cocoa Find panel, paid via PayPal or moneybookers. If the work is done by multiple people, it'll obviously be split fairly. As I'm CC'd to the bug, I'll know when someone's working on it, and will try and pay as soon as someone can confirm that the patch works without causing major regressions.
I thought an ealier version of TextEdit had this implemented separately (it has since been integrated into the cocoa text system). If someone had access to that code it might show the way.
Created attachment 10723 [details] performFindPanelAction interface and implementation to add to WebView interface and implementation I took a stab at this. I'm not that familiar with the inner workings of WebKit and not really familiar enoght with c++ to poke around there. However, using just the public objective-C APIs I think I have an initial stab at this. What I've done is independent of the AppKit. It deos add many methods to WebView to implement fully (see the .h file). It doesn't yet implement: 1) "replace all" or 2) "replace all within selection". I think those should be implemented so that they are undoable in one undo action. It also doesn't undo replace string when the string is an empty string. I'm not familiar enough with WebView protocols to know how best to implement those undos. The standard Find Panel has a popup for selecting "Contains", "Full word" or "Starts with". I have not implemented either: 3) "Full word" or 4) "Starts with" Also I added an NSLocalizedString for the "Not Found" message on the standard find panel for localization. This would require 5) a Localizable.strings file to finish implementing. I've included a nib file with an approximation of the standard Find Panel. This could alternately be created with HTML forms or .Net, or XWindows, etc. It merely provides a UI to set the other instance variables, invoke performFindPanelActions and, for performFindPanelAction == 1, to have a panel to display. If one were to remove the popup button, and the replace all button this implementation is ready as is.
Created attachment 10724 [details] implementation file
Created attachment 10725 [details] nib with pseudo-standard find panel (text archive format) This si a nib file containing an approximation of the standard Find Panel (from TextEdit). The tags are set approrpiately on the round buttons and can be wired to the performFindPanelAction of the first responder. The checkboxes can be bound, wireed or otherwise linked up to the appropriate methods included in this interface. Likewise the notfound. The enclosed NSPanel should then be sent as the argument like: [aWebView setFindPanel:thisFindPanel] As an alternative, a different find panel could be created using another UI enviornment of even HTML forms. The performFindPanel method does require the sender invoking the message repsond to introspection through the "tag" method.
Just by way of reference, I wanted to provide a link to the Apple documentation ont performFindPanelAction (specifically the constant tag integers used). You'll find them here: http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextView_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSFindPanelActionShowFindPanel I think for the benefit of appKit users it might mkae sense to add IBOutlets for: 1) searchStringField 2) replaceStringField 3) searchWrapsAroundFlag 4) caseSensitiveSearchFlag That way those ivars can be wired up to a find panel. Just a thought to deal with the need to update those ivars from the find panel immediately before a search takes place.
Created attachment 10727 [details] image of sample xhtml find panel Here's another proto-idea to make this even more independent of the AppKit. We could have a default find panel that could be overridden by using the setFindPanel method. This deffault find panel would be another WebView populated with XHTML UI controls and laid out with CSS (attachment forthcoming. This is just an image of what it looks like now. The CSS keyword "caption" for the system font does not seem to work (I'll file a bug). This could also use the pinstripe Augua background for Mac OS X or some others for other systems. I call it a proto idea, becuase I'm not familiar enough with WebKit (and all the other necessary technologies) to know whether there's a way to invoke actions from this WebView on other WebViews that are the first responder to thes actions. If anyone has some ideas on this I'd be happy to work on it.
Created attachment 10728 [details] find panel in xhtml Here is the sample xhtml for a buil in cross-platform find-pane independent of AppKit (at least as indpendent as anything else in WebKit). The CSS could use some improving, but more importantly we would need a mechnaism for this find panel to invoke the performFindPanelAction method in the first responder chain. We could aslo generate this find panel using the DOM (and with CSS) have a flexible localized find panel.
Created attachment 10729 [details] xhtml find panel (revision)
Is this still a valid bug?
The "unimplemented" error message is still there. Why are you asking?
The last comment was 6 years ago. :) Just figured someone should check in. :)
Hard to say if this is still relevant. -performFindPanelAction: has mostly been replaced by NSTextFinder, but having NSTextFinder support (via a subclass perhaps?) in WebView would still be quite helpful.
I found this WebView subclass implementation to be a helpful starting point: https://github.com/shc-vj/SHCWebView