|
| 1 | +<!-- USAGE |
| 2 | + * Fill in each of the sections (like Background) below |
| 3 | + * Wrap code with `single line of code` or ```code block``` |
| 4 | + * Before submitting, delete all <!-- TEMPLATE marked comments in this file, |
| 5 | + and the following quote banner: |
| 6 | +--> |
| 7 | +# Background |
| 8 | +The browser has a Status bar that displays text when hovering over a link, or performing some activity. Currently, |
| 9 | +Developers are able to opt in to disable showing the status bar through the browser |
| 10 | +settings. |
| 11 | + |
| 12 | +Developers would also like to be able to opt in to intercept the updates which would |
| 13 | +normally be displayed by the Status bar, and show it using thier own custom UI. |
| 14 | +# Description |
| 15 | +We propose two new events for WebView2 that would allow developers to |
| 16 | +listen for Status bar updates which are triggered by activity on the embedded |
| 17 | +browser, and then handle those updates however they want in their applications. |
| 18 | + |
| 19 | +Developers will be able to: |
| 20 | + |
| 21 | +1) Register an even handler for knowing when to show the status bar and what text to show |
| 22 | +2) Register an handler for knowing when the browser wants to dismiss the status bar |
| 23 | + |
| 24 | + |
| 25 | +# Examples |
| 26 | +## Win32 C++ Registering a listener for status bar showing |
| 27 | +``` |
| 28 | +CHECK_FAILURE(m_webView->add_StatusBarShowing( |
| 29 | + Callback<ICoreWebView2StatusBarShowingEventHandler>( |
| 30 | + [this](ICoreWebView2* sender, ICoreWebView2StatusBarShowingEventArgs* args) -> HRESULT { |
| 31 | + std::string message; |
| 32 | + CHECK_FAILURE(args->get_message(&message)); |
| 33 | + |
| 34 | + // Handle status bar text in message |
| 35 | +
|
| 36 | + return S_OK; |
| 37 | + } |
| 38 | + ).Get(), |
| 39 | +&m_statusBarShowing)); |
| 40 | +``` |
| 41 | +## Win32 C++ Registering a listener for status bar hiding |
| 42 | +``` |
| 43 | +CHECK_FAILURE(m_webView->add_StatusBarHiding( |
| 44 | + Callback<ICoreWebView2StatusBarHidingEventHandler>( |
| 45 | + [this](ICoreWebView2* sender) -> HRESULT { |
| 46 | + |
| 47 | + // Dismiss status bar |
| 48 | +
|
| 49 | + return S_OK; |
| 50 | + } |
| 51 | + ).Get(), |
| 52 | +&m_statusBarHiding)); |
| 53 | +``` |
| 54 | +## C#/ .Net/ WinRT Registering a listener for status bar showing |
| 55 | +``` |
| 56 | +webView.CoreWebView2.StatusBarShowing += (object sender, CoreWebView2StatusBarShowingEventArgs arg) => |
| 57 | +{ |
| 58 | + string message = args.message; |
| 59 | + // Handle status bar text in message |
| 60 | +}; |
| 61 | +``` |
| 62 | +## C#/ .Net/ WinRT Registering a listener for status bar hiding |
| 63 | +``` |
| 64 | +webView.CoreWebView2.StatusBarHiding += (object sender) => |
| 65 | +{ |
| 66 | + // Dismiss status bar |
| 67 | +}; |
| 68 | +``` |
| 69 | +# API Notes |
| 70 | +See [API Details](#api-details) Section below for API reference |
| 71 | +# API Details |
| 72 | +## Win32 C++ |
| 73 | +``` |
| 74 | +interface ICoreWebView2StatusBarShowingEventArgs : IUnknown { |
| 75 | + [propget] HRESULT message([out, retval] std::string* message); |
| 76 | +} |
| 77 | + |
| 78 | +interface ICoreWebView2StatusBarShowingEventHandler : IUnknown { |
| 79 | + /// Called to provide the implementer with the event args for the |
| 80 | + /// corresponding event. |
| 81 | + HRESULT Invoke( |
| 82 | + [in] ICoreWebView2* sender, |
| 83 | + [in] ICoreWebView2StatusBarShowingEventArgs* args); |
| 84 | +} |
| 85 | +
|
| 86 | +interface ICoreWebView2StatusBarHidingEventHandler : IUnknown { |
| 87 | + /// Called to provide the implementer with the event args for the |
| 88 | + /// corresponding event. |
| 89 | + HRESULT Invoke( |
| 90 | + [in] ICoreWebView2* sender); |
| 91 | +} |
| 92 | +``` |
| 93 | +## C#/ .Net/ WinRT |
| 94 | +``` |
| 95 | +namespace Microsoft.Web.WebView2.Core { |
| 96 | +
|
| 97 | +
|
| 98 | + runtimeclass CoreWebView2StatusBarShowingEventArgs { |
| 99 | + string message {get;}; |
| 100 | + } |
| 101 | +
|
| 102 | + runtimeclass CoreWebView2 { |
| 103 | + event Windows.Foundation.TypedEventHandler<CoreWebView2, CoreWebView2StatusBarShowingEventArgs> StatusBarShowingEvent; |
| 104 | + } |
| 105 | +
|
| 106 | + runtimeclass CoreWebView2 { |
| 107 | + event Windows.Foundation.TypedEventHandler<CoreWebView2> StatusBarHidingEvent; |
| 108 | + } |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | + |
| 113 | +# Appendix |
| 114 | +<!-- TEMPLATE |
| 115 | + Anything else that you want to write down for posterity, but |
| 116 | + that isn't necessary to understand the purpose and usage of the API. |
| 117 | + For example, implementation details or links to other resources. |
| 118 | +--> |
| 119 | +See here for more details about the Status bar: <a href="https://www.computerhope.com/jargon/s/statusbar.htm">Here</a> |
0 commit comments