Skip to content

Commit 0584cad

Browse files
authored
Merge pull request #1414 from MicrosoftEdge/api-status-bar-activity-draft
Api status bar activity draft
2 parents 63dbaa5 + fd8108f commit 0584cad

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

specs/StatusBarMessage.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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 messages which would
13+
normally be displayed by the Status bar, and show it using thier own custom UI.
14+
# Description
15+
We propose a new event for WebView2 that would allow developers to
16+
listen for Status bar updates which are triggered by activity on the WebView, and then handle those updates however they want in their applications.
17+
18+
Developers will be able to register an event handler for changes to the status bar message.
19+
# Examples
20+
## Win32 C++ Registering a listener for status bar message changes
21+
```
22+
CHECK_FAILURE(m_webView->add_StatusBarMessageChanged(
23+
Microsoft::WRL::Callback<ICoreWebView2StatusBarMessageChangedEventHandler>(
24+
[this](ICoreWebView2* sender, IUnknown* args) -> HRESULT
25+
{
26+
27+
LPWSTR value;
28+
CHECK_FAILURE(sender->get_StatusBarMessage(&value));
29+
if (wcslen(value) != 0)
30+
{
31+
32+
m_statusBar.show(value);
33+
} else {
34+
35+
m_statusBar.hide();
36+
}
37+
38+
return S_OK;
39+
}
40+
).Get(),
41+
&m_statusBarMessageChangedToken));
42+
```
43+
## .NET / WinRT Registering a listener for status bar message changes
44+
```
45+
webView.CoreWebView2.StatusBarMessageChanged += (CoreWebView2 sender, Object arg) =>
46+
{
47+
string value = sender.statusBarMessage;
48+
// Handle status bar text in value
49+
if (value.Length != 0) {
50+
statusBar.show(value);
51+
} else {
52+
statusBar.hide();
53+
}
54+
55+
};
56+
```
57+
# API Notes
58+
See [API Details](#api-details) Section below for API reference
59+
# API Details
60+
## Win32 C++
61+
```
62+
/// Interface for the status bar message changed event handler
63+
[uuid(85c8b75a-ceac-11eb-b8bc-0242ac130003), object, pointer_default(unique)]
64+
interface ICoreWebView2StatusBarMessageChangedEventHandler : IUnknown {
65+
/// Called to provide the implementer with the event args for the
66+
/// corresponding event.
67+
HRESULT Invoke(
68+
[in] ICoreWebView2* sender,
69+
[in] IUnknown* args);
70+
}
71+
72+
[uuid(b2c01782-ceaf-11eb-b8bc-0242ac130003), object, pointer_default(unique)]
73+
interface ICoreWebView2_5 : ICoreWebView2_4 {
74+
/// Add an event handler for the `StatusBarMessageChanged` event.
75+
/// `StatusBarMessageChanged` runs when the WebView statusbar content changes
76+
/// status bar
77+
HRESULT add_StatusBarMessageChanged(
78+
[in] ICoreWebView2StatusBarMessageChangedEventHandler* eventHandler,
79+
[out] EventRegistrationToken* token);
80+
81+
/// Removing the event handler for `StatusBarMessageChanged` event
82+
HRESULT remove_StatusBarMessageChanged(
83+
[in] EventRegistrationToken token);
84+
85+
/// used to access the current value of the status bar message
86+
[propget] HRESULT StatusBarMessage([out, retval] LPWSTR* value);
87+
}
88+
```
89+
## .Net/ WinRT
90+
```
91+
namespace Microsoft.Web.WebView2.Core {
92+
93+
/// Interface for the status bar message changed event handler
94+
runtimeclass CoreWebView2 {
95+
event Windows.Foundation.TypedEventHandler<CoreWebView2, Object> StatusBarMessageChanged;
96+
string StatusBarMessage {get;};
97+
}
98+
}
99+
```
100+
# Appendix
101+
<!-- TEMPLATE
102+
Anything else that you want to write down for posterity, but
103+
that isn't necessary to understand the purpose and usage of the API.
104+
For example, implementation details or links to other resources.
105+
-->
106+
See here for more details about the Status bar: <a href="https://www.computerhope.com/jargon/s/statusbar.htm">Here</a>

0 commit comments

Comments
 (0)