共用方式為


WebViewControl.GotFocus 事件

定義

WebViewControl 收到焦點 (時,通知您的應用程式,因為使用者按一下 WebViewControl) 內部/外部。 使用WebViewControl.MoveFocus方法搭配LostFocus事件和程式設計焦點變更。

// Register
event_token GotFocus(TypedEventHandler<WebViewControl, IInspectable const&> const& handler) const;

// Revoke with event_token
void GotFocus(event_token const* cookie) const;

// Revoke with event_revoker
WebViewControl::GotFocus_revoker GotFocus(auto_revoke_t, TypedEventHandler<WebViewControl, IInspectable const&> const& handler) const;
public event TypedEventHandler<WebViewControl,object> GotFocus;
function onGotFocus(eventArgs) { /* Your code */ }
webViewControl.addEventListener("gotfocus", onGotFocus);
webViewControl.removeEventListener("gotfocus", onGotFocus);
- or -
webViewControl.ongotfocus = onGotFocus;
Public Custom Event GotFocus As TypedEventHandler(Of WebViewControl, Object) 

事件類型

Windows 需求

裝置系列
Windows 10, version 1809 (已於 10.0.17763.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v7.0 引進)

範例

下列 C# 範例示範搭配 WebViewControl 使用 GotFocus 和 LostFocus 的事件:

WebViewControl webViewControl; 

void WebViewControlGotFocus(WebViewControl sender, IInspectable args) 
{ 
    AddFocusHighlightToElement(sender); 
} 

void WebViewControlLostFocus(WebViewControl sender, IInspectable args) 
{ 
    RemoveFocusHighlightFromElement(sender); 
} 

webViewControl.GotFocus += WebViewControlGotFocus; 
webViewControl.LostFocus += WebViewControlLostFocus

GotFocus 和 LostFocus 事件會在 WebViewControl 收到或失去焦點時告知應用程式。 這可能是因為呼叫 MoveFocus,或使用者按一下 WebViewControl 內部/外部。

適用於