@@ -337,6 +337,100 @@ interface ICoreWebView2Find : IUnknown {
337337}
338338```
339339
340+
341+ ### Setting Up Find Configuration
342+
343+ ``` csharp
344+ public enum CoreWebView2FindDirection
345+ {
346+ Forward ,
347+ Backward
348+ }
349+
350+ public class CoreWebView2FindConfiguration
351+ {
352+ public string FindTerm { get ; set ; }
353+ public CoreWebView2FindDirection FindDirection { get ; set ; }
354+ public bool IsCaseSensitive { get ; set ; }
355+ public bool ShouldMatchWord { get ; set ; }
356+ }
357+ ```
358+
359+ ### Starting a Find Operation
360+
361+ ``` csharp
362+ public interface ICoreWebView2StagingFind
363+ {
364+ Task StartFindAsync (CoreWebView2FindConfiguration configuration );
365+ void FindNext ();
366+ void FindPrevious ();
367+ void StopFind ();
368+ bool ShouldHighlightAllMatches { get ; set ; }
369+ bool ShouldHighlightActiveMatch { get ; set ; }
370+ bool UseCustomUI { get ; set ; }
371+ int ActiveMatchIndex { get ; }
372+ int MatchesCount { get ; }
373+ void PassHighlightSettings ();
374+ }
375+
376+ // Usage example:
377+ public async Task PerformFindOperation (ICoreWebView2StagingFind webViewFind )
378+ {
379+ var findConfig = new CoreWebView2FindConfiguration
380+ {
381+ FindTerm = " example" ,
382+ FindDirection = CoreWebView2FindDirection .Forward ,
383+ IsCaseSensitive = false ,
384+ ShouldMatchWord = true
385+ };
386+
387+ await webViewFind .StartFindAsync (findConfig );
388+ webViewFind .FindNext ();
389+ // Further operations...
390+ }
391+ ```
392+
393+ ### Handling Find Operation Events
394+
395+ ``` csharp
396+ public interface ICoreWebView2StagingFindMatchCountChangedEventHandler
397+ {
398+ void OnMatchCountChanged (ICoreWebView2StagingFind sender );
399+ }
400+
401+ public interface ICoreWebView2StagingFindActiveMatchIndexChangedEventHandler
402+ {
403+ void OnActiveMatchIndexChanged (ICoreWebView2StagingFind sender );
404+ }
405+
406+ public interface ICoreWebView2StagingFindOperationCompletedHandler
407+ {
408+ void OnFindOperationCompleted (ICoreWebView2StagingFind sender );
409+ }
410+
411+ public void SubscribeToFindEvents (ICoreWebView2StagingFind webViewFind )
412+ {
413+ webViewFind .MatchCountChanged += OnMatchCountChanged ;
414+ webViewFind .ActiveMatchIndexChanged += OnActiveMatchIndexChanged ;
415+ webViewFind .FindOperationCompleted += OnFindOperationCompleted ;
416+ }
417+
418+ private void OnMatchCountChanged (ICoreWebView2StagingFind sender )
419+ {
420+ Console .WriteLine ($" Match count changed. New count: {sender .MatchesCount }" );
421+ }
422+
423+ private void OnActiveMatchIndexChanged (ICoreWebView2StagingFind sender )
424+ {
425+ Console .WriteLine ($" Active match index changed. New index: {sender .ActiveMatchIndex }" );
426+ }
427+
428+ private void OnFindOperationCompleted (ICoreWebView2StagingFind sender )
429+ {
430+ Console .WriteLine (" Find operation completed." );
431+ }
432+ ```
433+
340434# Appendix
341435
342436This API specification focuses on providing developers with the necessary information to integrate text finding and navigation functionalities into WebView2 applications.
0 commit comments