// Copyright © 2021 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
namespace CefSharp.Handler
{
///
/// Implement this interface to handle events related to focus.
/// The methods of this class will be called on the CEF UI thread.
///
public class FocusHandler : IFocusHandler
{
///
/// Called when the browser component has received focus.
///
/// the ChromiumWebBrowser control
/// the browser object
void IFocusHandler.OnGotFocus(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
OnGotFocus(chromiumWebBrowser, browser);
}
///
/// Called when the browser component has received focus.
///
/// the ChromiumWebBrowser control
/// the browser object
protected virtual void OnGotFocus(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
}
///
/// Called when the browser component is requesting focus.
///
/// the ChromiumWebBrowser control
/// the browser object, do not keep a reference to this object outside of this method
/// Indicates where the focus request is originating from.
/// Return false to allow the focus to be set or true to cancel setting the focus.
bool IFocusHandler.OnSetFocus(IWebBrowser chromiumWebBrowser, IBrowser browser, CefFocusSource source)
{
return OnSetFocus(chromiumWebBrowser, browser, source);
}
///
/// Called when the browser component is requesting focus.
///
/// the ChromiumWebBrowser control
/// the browser object, do not keep a reference to this object outside of this method
/// Indicates where the focus request is originating from.
/// Return false to allow the focus to be set or true to cancel setting the focus.
protected virtual bool OnSetFocus(IWebBrowser chromiumWebBrowser, IBrowser browser, CefFocusSource source)
{
return false;
}
///
/// Called when the browser component is about to lose focus.
/// For instance, if focus was on the last HTML element and the user pressed the TAB key.
///
/// the ChromiumWebBrowser control
/// the browser object
/// Will be true if the browser is giving focus to the next component
/// and false if the browser is giving focus to the previous component.
void IFocusHandler.OnTakeFocus(IWebBrowser chromiumWebBrowser, IBrowser browser, bool next)
{
OnTakeFocus(chromiumWebBrowser, browser, next);
}
///
/// Called when the browser component is about to lose focus.
/// For instance, if focus was on the last HTML element and the user pressed the TAB key.
///
/// the ChromiumWebBrowser control
/// the browser object
/// Will be true if the browser is giving focus to the next component
/// and false if the browser is giving focus to the previous component.
protected virtual void OnTakeFocus(IWebBrowser chromiumWebBrowser, IBrowser browser, bool next)
{
}
}
}