WinForms - SetFocus to ChromiumWebBrowser when browser has initialized
You can now type directly into the Google search box
This commit is contained in:
parent
be687cb0b7
commit
c0d667fc7a
@ -26,6 +26,7 @@ namespace CefSharp.MinimalExample.WinForms
|
||||
};
|
||||
toolStripContainer.ContentPanel.Controls.Add(browser);
|
||||
|
||||
browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged;
|
||||
browser.LoadingStateChanged += OnLoadingStateChanged;
|
||||
browser.ConsoleMessage += OnBrowserConsoleMessage;
|
||||
browser.StatusMessage += OnBrowserStatusMessage;
|
||||
@ -37,6 +38,16 @@ namespace CefSharp.MinimalExample.WinForms
|
||||
DisplayOutput(version);
|
||||
}
|
||||
|
||||
private void OnIsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e)
|
||||
{
|
||||
if(e.IsBrowserInitialized)
|
||||
{
|
||||
var b = ((ChromiumWebBrowser)sender);
|
||||
|
||||
this.InvokeOnUiThreadIfRequired(() => b.Focus());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBrowserConsoleMessage(object sender, ConsoleMessageEventArgs args)
|
||||
{
|
||||
DisplayOutput(string.Format("Line: {0}, Source: {1}, Message: {2}", args.Line, args.Source, args.Message));
|
||||
|
Loading…
Reference in New Issue
Block a user