|
2 | 2 |
|
3 | 3 | ## Background |
4 | 4 |
|
5 | | -The WebView2Find API provides methods and events to support text finding and navigation within a WebView2 control. |
6 | | -It allows developers to programmatically initiate find operations, navigate between find results, supress default UI, customize various find configurations |
7 | | -such as query, direction of search, match case, match word, etc. Also enables developers to track the status of ongoing operations such as whether a find session has |
8 | | -completed or not, whether the match count has changed, and whether the match index has changed. |
| 5 | +The WebView2Find API offers methods and events for text finding and navigation |
| 6 | +within a WebView2 control. It enables developers to programmatically initiate find |
| 7 | +operations, navigate find results, suppress default UI, and customize find configurations |
| 8 | +like query and search direction. It also tracks the status of operations, indicating |
| 9 | +completion, match count changes, and match index changes. |
9 | 10 |
|
10 | 11 | ## Examples |
11 | 12 |
|
12 | 13 |
|
13 | 14 | #### Description |
14 | | -To initiate a find operation within a WebView2 control, developers can utilize the `StartFind` method. |
15 | | -This method allows specifying the find term and configuring other find parameters using the `ICoreWebView2FindConfiguration` interface. |
16 | | -Additionally there can only be one find session active per webview environment. |
17 | | -If an attempt is made to call start find more than once with the same findconfugration, |
18 | | -it will result in the active match index either being increased or decreased depending on what |
19 | | -Find Direction parameter was chosen for the Find Configuration. |
20 | 15 |
|
| 16 | +To initiate a find operation in a WebView2 control, use the `StartFind` method. |
| 17 | +This method allows setting the search term and find parameters via the |
| 18 | +`ICoreWebView2FindConfiguration` interface. Only one find session can be active per |
| 19 | +webview environment. Starting another with the same configuration will adjust |
| 20 | +the active match index based on the selected Find Direction. |
21 | 21 | #### Create/Specify a Find Configuration |
22 | 22 | ```cpp |
23 | 23 |
|
@@ -124,7 +124,8 @@ async void ConfigureAndExecuteFindAsync(string searchTerm){ |
124 | 124 | ### Retrieve the Number of Matches |
125 | 125 |
|
126 | 126 | #### Description |
127 | | -To retrieve the total number of matches found during a find operation within a WebView2 control, developers can utilize the `GetMatchCount` method. |
| 127 | +To retrieve the total number of matches found during a find operation |
| 128 | +within a WebView2 control, developers can utilize the `GetMatchCount` method. |
128 | 129 |
|
129 | 130 |
|
130 | 131 | ```cpp |
@@ -152,7 +153,8 @@ To retrieve the total number of matches found during a find operation within a W |
152 | 153 | //! [GetMatchCount] |
153 | 154 | public async Task<int> GetMatchCountAsync() |
154 | 155 | { |
155 | | - var webViewFind = webView.CoreWebView2.FindController; // Assuming webView is your WebView2 control |
| 156 | + // Assuming webView is your WebView2 control |
| 157 | + var webViewFind = webView.CoreWebView2.FindController; |
156 | 158 | var matchCount = await webViewFind.GetMatchesCountAsync(); |
157 | 159 | MessageBox.Show($"Match Count: {matchCount}", "Find Operation", MessageBoxButton.OK); |
158 | 160 | return matchCount; |
@@ -210,7 +212,8 @@ void ActiveMatchIndexChangedSample() |
210 | 212 | ### Retrieve the Index of the Active Match |
211 | 213 |
|
212 | 214 | #### Description |
213 | | -Developers can retrieve the index of the currently active match within a WebView2 control using the `GetActiveMatchIndex` method. |
| 215 | +Developers can retrieve the index of the currently active match |
| 216 | +within a WebView2 control using the `GetActiveMatchIndex` method. |
214 | 217 |
|
215 | 218 |
|
216 | 219 | ```cpp |
@@ -372,7 +375,11 @@ interface ICoreWebView2Find : IUnknown { |
372 | 375 |
|
373 | 376 | ### Setting Up Find Configuration with MIDL3 |
374 | 377 |
|
375 | | -To represent the given C# examples in a manner consistent with the behavior demonstrated earlier in the chat and align them with an API design that could be described using MIDL3 (noted as C# for formatting), let's formalize the design for a hypothetical WebView2 Find operation API. This design will incorporate setting up a find configuration, starting a find operation, handling find operation events, and navigating through find matches. |
| 378 | +To represent the given C# examples in a manner consistent with the behavior demonstrated |
| 379 | +earlier in the chat and align them with an API design that could be described using |
| 380 | +MIDL3 (noted as C# for formatting), let's formalize the design for a hypothetical |
| 381 | +WebView2 Find operation API. This design will incorporate setting up a find configuration, |
| 382 | + starting a find operation, handling find operation events, and navigating through find matches. |
376 | 383 |
|
377 | 384 | ### CoreWebView2 Find Configuration and Direction |
378 | 385 |
|
@@ -440,13 +447,20 @@ namespace Microsoft.Web.WebView2.Core |
440 | 447 | } |
441 | 448 | ``` |
442 | 449 |
|
443 | | -These examples demonstrate how you would conceptualize and implement the Find API within the Microsoft WebView2 environment, focusing on async patterns for responsive UI interactions and event handling for dynamic UI updates based on the results of find operations. |
444 | | -This design emphasizes asynchronous task-based APIs, event handling for UI updates, and modular API design for clear separation of concerns. |
| 450 | +These examples demonstrate how you would conceptualize and implement the Find API |
| 451 | +within the Microsoft WebView2 environment, focusing on async patterns for |
| 452 | +responsive UI interactions and event handling for dynamic UI updates based on the |
| 453 | +results of find operations. This design emphasizes asynchronous task-based APIs, |
| 454 | +event handling for UI updates, and modular API design for clear separation of concerns. |
445 | 455 |
|
446 | 456 | # Appendix |
447 | 457 |
|
448 | | -This API specification focuses on providing developers with the necessary information to integrate text finding and navigation functionalities into WebView2 applications. |
449 | | -It emphasizes the usage of interfaces such as `ICoreWebView2Find` and `ICoreWebView2FindConfiguration` to perform find operations effectively. |
| 458 | +This API specification focuses on providing developers with the necessary information |
| 459 | +to integrate text finding and navigation functionalities into WebView2 applications. |
| 460 | +It emphasizes the usage of interfaces such as `ICoreWebView2Find` and |
| 461 | +`ICoreWebView2FindConfiguration` to perform find operations effectively. |
| 462 | + |
450 | 463 | Additional Info: |
451 | | -Starting a find session when one is in progress will result in the active match index being moved forward or backwards depending on what find configuration has been used |
| 464 | +Starting a find session when one is in progress will result in the active match index |
| 465 | +being moved forward or backwards depending on what find configuration has been used |
452 | 466 | (forward,backward). |
0 commit comments