44
55The WebView2Find API offers methods and events for text finding and navigation
66within a WebView2 control. It enables developers to programmatically initiate find
7- operations, navigate find results, suppress default UI, and customize find configurations
7+ operations, navigate find results, suppress default UI, and customize find options
88like query and find direction. It also tracks the status of operations, indicating
99completion, match count changes, and match index changes.
1010
@@ -26,34 +26,34 @@ completion, match count changes, and match index changes.
2626
2727To initiate a find operation in a WebView2 control, use the ` StartFindAsync ` method.
2828This method allows setting the find term and find parameters via the
29- ` ICoreWebView2FindConfiguration ` interface. Only one find session can be active per
30- webview environment. Starting another with the same configuration will adjust
29+ ` ICoreWebView2FindOptions ` interface. Only one find session can be active per
30+ webview environment. Starting another with the same option will adjust
3131the active match index based on the selected Find Direction.
32- ### Create/Specify a Find Configuration
32+ ### Create/Specify a Find Option
3333#### WIN32 C++
3434
3535``` cpp
3636
37- wil::com_ptr<ICoreWebView2FindConfiguration > AppWindow::InitializeFindConfiguration (const std::wstring& findTerm)
37+ wil::com_ptr<ICoreWebView2FindOptions > AppWindow::InitializeFindOptions (const std::wstring& findTerm)
3838{
3939 // Query for the ICoreWebView2Environment5 interface.
4040 auto webView2Environment5 = m_webViewEnvironment.try_query<ICoreWebView2Environment5 >();
4141 CHECK_FEATURE_RETURN(webView2Environment5);
4242
43- // Initialize find configuration/settings
44- wil::com_ptr<ICoreWebView2FindConfiguration> findConfiguration ;
45- CHECK_FAILURE(webView2Environment5->CreateFindConfiguration(&findConfiguration ));
46- CHECK_FAILURE(findConfiguration ->put_FindTerm(findTerm.c_str()));
43+ // Initialize find options
44+ wil::com_ptr<ICoreWebView2FindOptions> find_options ;
45+ CHECK_FAILURE(webView2Environment5->CreateFindOptions(&find_options ));
46+ CHECK_FAILURE(find_options ->put_FindTerm(findTerm.c_str()));
4747
48- return findConfiguration ;
48+ return find_options ;
4949}
5050```
5151
5252```cpp
5353bool AppWindow::ConfigureAndExecuteFind(const std::wstring& findTerm)
5454{
55- auto findConfiguration = InitializeFindConfiguration (findTerm);
56- if (!findConfiguration )
55+ auto find_options = InitializeFindOptions (findTerm);
56+ if (!find_options )
5757 {
5858 return false;
5959 }
@@ -70,7 +70,7 @@ bool AppWindow::ConfigureAndExecuteFind(const std::wstring& findTerm)
7070
7171 // Start the find operation with a callback for completion.
7272 CHECK_FAILURE(webView2Find->StartFind(
73- findConfiguration .get(),
73+ find_options .get(),
7474 Callback<ICoreWebView2FindOperationCompletedHandler>(
7575 [this](HRESULT result, BOOL status) -> HRESULT
7676 {
@@ -93,8 +93,8 @@ bool AppWindow::ConfigureAndExecuteFind(const std::wstring& findTerm)
9393``` cpp
9494bool AppWindow::ExecuteFindWithCustomUI (const std::wstring& findTerm)
9595{
96- auto findConfiguration = InitializeFindConfiguration (findTerm);
97- if (!findConfiguration )
96+ auto find_options = InitializeFindOptions (findTerm);
97+ if (!find_options )
9898 {
9999 return false;
100100 }
@@ -111,7 +111,7 @@ bool AppWindow::ExecuteFindWithCustomUI(const std::wstring& findTerm)
111111
112112 // Start the find operation with callback for completion.
113113 CHECK_FAILURE(webView2Find->StartFind(
114- findConfiguration .get(),
114+ find_options .get(),
115115 Callback<ICoreWebView2FindOperationCompletedHandler>(
116116 [this](HRESULT result, BOOL status) -> HRESULT
117117 {
@@ -147,17 +147,17 @@ async Task ConfigureAndExecuteFindWithDefaultUIAsync(string findTerm)
147147 throw new InvalidOperationException("WebView2 is not initialized.");
148148 }
149149
150- // Initialize the find configuration with specified settings.
151- var findConfiguration = new CoreWebView2FindConfiguration
150+ // Initialize the find options with specified settings.
151+ var find_options = new CoreWebView2FindOptions
152152 {
153153 FindTerm = findTerm
154154 };
155155
156156 // By default Find will use the default UI and highlight all matches. If you want different behavior
157157 // you can change the SuppressDefaultDialog and ShouldHighlightAllMatches properties here.
158158
159- // Start the find operation with the specified configuration .
160- await webView.CoreWebView2.Find.StartFindAsync(findConfiguration );
159+ // Start the find operation with the specified options .
160+ await webView.CoreWebView2.Find.StartFindAsync(find_options );
161161
162162 // End user interaction is handled via UI.
163163 }
@@ -180,8 +180,8 @@ async Task ConfigureAndExecuteFindWithCustomUIAsync(string findTerm)
180180 throw new InvalidOperationException (" WebView2 is not initialized." );
181181 }
182182
183- // Initialize the find configuration with specified settings .
184- var findConfiguration = new CoreWebView2FindConfiguration
183+ // Initialize the find options .
184+ var find_options = new CoreWebView2FindOptions
185185 {
186186 FindTerm = findTerm
187187 };
@@ -190,8 +190,8 @@ async Task ConfigureAndExecuteFindWithCustomUIAsync(string findTerm)
190190 webView .CoreWebView2 .Find .SuppressDefaultDialog = true ;
191191 webView .CoreWebView2 .Find .ShouldHighlightAllMatches = true ;
192192
193- // Start the find operation with the specified configuration .
194- await webView .CoreWebView2 .Find .StartFindAsync (findConfiguration );
193+ // Start the find operation with the specified options .
194+ await webView .CoreWebView2 .Find .StartFindAsync (find_options );
195195 // It's expected that the custom UI for navigating between matches (next, previous)
196196 // and stopping the find operation will be managed by the developer's custom code.
197197 }
@@ -275,16 +275,16 @@ typedef enum COREWEBVIEW2_FIND_DIRECTION {
275275
276276
277277// / Interface that provides methods related to the environment settings of CoreWebView2.
278- // / This interface allows for the creation of new find configuration objects.
278+ // / This interface allows for the creation of new find options objects.
279279// MSOWNERS: core (maxwellmyers@microsoft.com)
280280[uuid(f10bddd3-bb59-5d5b-8748 -8a1a53f65d0c), object, pointer_default(unique)]
281281interface ICoreWebView2StagingEnvironment5 : IUnknown {
282- /// Creates a new instance of a FindConfiguration object.
283- /// This configuration object can be used to define parameters for a find operation.
284- /// Returns the newly created FindConfiguration object.
282+ /// Creates a new instance of a FindOptions object.
283+ /// This options object can be used to define parameters for a find operation.
284+ /// Returns the newly created FindOptions object.
285285 // MSOWNERS: core (maxwellmyers@microsoft.com )
286- HRESULT CreateFindConfiguration (
287- [ out, retval] ICoreWebView2StagingFindConfiguration ** value
286+ HRESULT CreateFindOptions (
287+ [ out, retval] ICoreWebView2StagingFindOptions ** value
288288 );
289289
290290
@@ -378,14 +378,14 @@ interface ICoreWebView2StagingFind : IUnknown {
378378 [ in] EventRegistrationToken token);
379379
380380
381- /// Initiates a find using the specified configuration .
381+ /// Initiates a find using the specified find option .
382382 /// Displays the Find bar and starts the find operation. If a find session was already ongoing, it will be stopped and replaced with this new instance.
383- /// If called with an empty string, the Find bar is displayed but no finding occurs. Changing the configuration object after initiation won't affect the ongoing find session.
384- /// To change the ongoing find session, StartFind must be called again with a new or modified configuration object.
383+ /// If called with an empty string, the Find bar is displayed but no finding occurs. Changing the find options object after initiation won't affect the ongoing find session.
384+ /// To change the ongoing find session, Start must be called again with a new or modified find options object.
385385 /// This method is primarily designed for HTML document queries.
386386 // MSOWNERS: core (maxwellmyers@microsoft.com )
387387 HRESULT StartFind(
388- [ in] ICoreWebView2StagingFindConfiguration * configuration
388+ [ in] ICoreWebView2StagingFindOptions * options
389389 , [ in] ICoreWebView2StagingFindStartFindCompletedHandler* handler
390390 );
391391
@@ -409,11 +409,11 @@ interface ICoreWebView2StagingFind : IUnknown {
409409
410410
411411
412- // / Interface defining the find configuration .
412+ // / Interface defining the find options .
413413// / This interface provides the necessary methods and properties to configure a find operation.
414414// MSOWNERS: core (maxwellmyers@microsoft.com)
415415[uuid(52a04b23-acc8-5659 -aa2f-26dbe9faafde), object, pointer_default(unique)]
416- interface ICoreWebView2StagingFindConfiguration : IUnknown {
416+ interface ICoreWebView2StagingFindOptions : IUnknown {
417417 /// Gets the ` FindDirection ` property.
418418 // MSOWNERS: core (maxwellmyers@microsoft.com )
419419 [ propget] HRESULT FindDirection([ out, retval] COREWEBVIEW2_FIND_DIRECTION* value);
@@ -476,7 +476,7 @@ interface ICoreWebView2Staging17 : IUnknown {
476476```
477477
478478
479- ### Setting Up Find Configuration with MIDL3
479+ ### Setting Up Find Options with MIDL3
480480
481481### CoreWebView2 Find Configuration and Direction
482482
@@ -510,25 +510,25 @@ namespace Microsoft.Web.WebView2.Core
510510 }
511511
512512 /// Interface that provides methods related to the environment settings of CoreWebView2.
513- /// This interface allows for the creation of new find configuration objects.
513+ /// This interface allows for the creation of new find options objects.
514514 [com_interface (" staging=ICoreWebView2StagingEnvironment5" )]
515515 [ms_owner (" core" , " maxwellmyers@microsoft.com" )]
516516 interface ICoreWebView2Environment15
517517 {
518- /// Creates a new instance of a CoreWebView2FindConfiguration object.
519- /// This configuration object can be used to define parameters for a find operation.
520- /// Returns the newly created FindConfiguration object.
521- CoreWebView2FindConfiguration CreateFindConfiguration ();
518+ /// Creates a new instance of a CoreWebView2FindOptions object.
519+ /// This find options object can be used to define parameters for a find operation.
520+ /// Returns the newly created FindOptions object.
521+ CoreWebView2FindOptions CreateFindOptions ();
522522 };
523523
524- runtimeclass CoreWebView2FindConfiguration : [default ]ICoreWebView2FindConfiguration {}
524+ runtimeclass CoreWebView2FindOptions : [default ]ICoreWebView2FindOptions {}
525525
526- /// Interface defining the find configuration .
526+ /// Interface defining the find options .
527527 /// This interface provides the necessary methods and properties to configure a find operation.
528- [com_interface (" staging=ICoreWebView2StagingFindConfiguration " )]
528+ [com_interface (" staging=ICoreWebView2StagingFindOptions " )]
529529 [ms_owner (" core" , " maxwellmyers@microsoft.com" )]
530530 [availability (" staging" )]
531- interface ICoreWebView2FindConfiguration
531+ interface ICoreWebView2FindOptions
532532 {
533533 /// Gets or sets the find term used for the find operation. Returns the find term.
534534 String FindTerm { get ; set ; };
@@ -574,10 +574,10 @@ runtimeclass CoreWebView2FindConfiguration : [default]ICoreWebView2FindConfigura
574574 interface ICoreWebView2Find
575575 {
576576 [completed_handler (" " )]
577- /// Initiates a find using the specified configuration asynchronously.
577+ /// Initiates a find using the specified options asynchronously.
578578 /// Displays the Find bar and starts the find operation. If a find session was already ongoing, it will be stopped and replaced with this new instance.
579- /// If called with an empty string, the Find bar is displayed but no finding occurs. Changing the configuration object after initiation won't affect the ongoing find session.
580- /// To change the ongoing find session, StartFindAsync must be called again with a new or modified configuration object.
579+ /// If called with an empty string, the Find bar is displayed but no finding occurs. Changing the find options object after initiation won't affect the ongoing find session.
580+ /// To change the ongoing find session, StartFindAsync must be called again with a new or modified find options object.
581581 /// StartFind supports, HTML, PDF, and TXT document queries. In general this api is designed for text based find sessions.
582582 // // If you start a find session programmatically on another file format that doesnt have text fields, the find session will try to execute but will fail to find any matches. (It will silently fail)
583583 // / Note: The asynchronous action completes when the UI has been displayed with the find term in the UI bar, and the matches have populated on the counter on the find bar.
@@ -591,7 +591,7 @@ runtimeclass CoreWebView2FindConfiguration : [default]ICoreWebView2FindConfigura
591591 // / regardless of the previous active match. This behavior indicates that changing the find query initiates a
592592 // / completely new find session, rather than continuing from the previous match index. This distinction is essential
593593 // / to understand when utilizing the StartFind method for navigating through text matches.
594- Windows.Foundation.IAsyncAction StartFindAsync (CoreWebView2FindConfiguration configuration );
594+ Windows.Foundation.IAsyncAction StartFindAsync (CoreWebView2FindOptions options );
595595
596596
597597 /// Navigates to the next match in the document.
@@ -643,6 +643,6 @@ runtimeclass CoreWebView2FindConfiguration : [default]ICoreWebView2FindConfigura
643643This API specification focuses on providing developers with the necessary information
644644to integrate text finding and navigation functionalities into WebView2 applications.
645645It emphasizes the usage of interfaces such as ` ICoreWebView2Find ` and
646- ` ICoreWebView2FindConfiguration ` to perform find operations effectively.
646+ ` ICoreWebView2FindOptions ` to perform find operations effectively.
647647
648648
0 commit comments