File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,12 @@ class DocumentationViewController: NSViewController {
110110
111111 // MARK:- Page search
112112
113+ @IBAction func searchDocumentation( _ sender: NSSearchField ) {
114+ let argsBytes = try ! JSONSerialization . data ( withJSONObject: [ " term " : sender. stringValue] )
115+ let args = NSString ( data: argsBytes, encoding: String . Encoding. utf8. rawValue) ! as String
116+ webView. evaluateJavaScript ( " search( ( \( args) )[ \" term \" ] ); " )
117+ }
118+
113119 func showSearchControl( ) {
114120 if viewerState != . ready {
115121 return
@@ -304,3 +310,10 @@ extension DocumentationViewController: SearchControlDelegate {
304310 webView. evaluateJavaScript ( " resetSearch(); " )
305311 }
306312}
313+
314+ // MARK:- NSSearchFieldDelegate
315+ extension DocumentationViewController : NSSearchFieldDelegate {
316+ func searchFieldDidEndSearching( _ sender: NSSearchField ) {
317+ webView. evaluateJavaScript ( " resetSearch(); " )
318+ }
319+ }
Original file line number Diff line number Diff line change 3333 <searchField key =" view" verticalHuggingPriority =" 750" textCompletion =" NO" id =" nuW-bv-dAc" >
3434 <rect key =" frame" x =" 0.0" y =" 0.0" width =" 100" height =" 21" />
3535 <autoresizingMask key =" autoresizingMask" />
36- <searchFieldCell key =" cell" scrollable =" YES" lineBreakMode =" clipping" selectable =" YES" editable =" YES" sendsActionOnEndEditing = " YES " borderStyle =" bezel" usesSingleLineMode =" YES" bezelStyle =" round" sendsSearchStringImmediately = " YES " id =" elf-l7-B2W" >
36+ <searchFieldCell key =" cell" scrollable =" YES" lineBreakMode =" clipping" selectable =" YES" editable =" YES" borderStyle =" bezel" usesSingleLineMode =" YES" bezelStyle =" round" recentsAutosaveName = " content-search-term " id =" elf-l7-B2W" >
3737 <font key =" font" usesAppearanceFont =" YES" />
3838 <color key =" textColor" name =" controlTextColor" catalog =" System" colorSpace =" catalog" />
3939 <color key =" backgroundColor" name =" textBackgroundColor" catalog =" System" colorSpace =" catalog" />
4040 </searchFieldCell >
41+ <connections >
42+ <action selector =" searchDocumentation:" target =" f61-KY-zVD" id =" ZAe-5r-fMu" />
43+ <outlet property =" delegate" destination =" f61-KY-zVD" id =" 6cm-hv-cR5" />
44+ </connections >
4145 </searchField >
4246 </searchToolbarItem >
4347 </allowedToolbarItems >
You can’t perform that action at this time.
0 commit comments