- Add CefFocusHandler::OnFocusedNodeChanged() notification (issue #379).

- Add CefDOMNode::IsFormControlElement() and CefDOMNode::GetFormControlElementType() methods (issue #379).
- Add space bar handling example to cefclient.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@318 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-10-14 12:40:40 +00:00
parent 06b7e9ab53
commit 9c6dcab73a
16 changed files with 267 additions and 12 deletions

View File

@@ -20,7 +20,8 @@ ClientHandler::ClientHandler()
m_BackHwnd(NULL),
m_ForwardHwnd(NULL),
m_StopHwnd(NULL),
m_ReloadHwnd(NULL)
m_ReloadHwnd(NULL),
m_bFormElementHasFocus(false)
{
}
@@ -201,6 +202,37 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
return false;
}
void ClientHandler::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node)
{
REQUIRE_UI_THREAD();
// Set to true if a form element has focus.
m_bFormElementHasFocus = (node.get() && node->IsFormControlElement());
}
bool ClientHandler::OnKeyEvent(CefRefPtr<CefBrowser> browser,
KeyEventType type,
int code,
int modifiers,
bool isSystemKey)
{
REQUIRE_UI_THREAD();
if (!m_bFormElementHasFocus && code == 0x20) {
// Special handling for the space character if a form element does not have
// focus.
if (type == KEYEVENT_RAWKEYDOWN) {
browser->GetMainFrame()->ExecuteJavaScript(
"alert('You pressed the space bar!');", "", 0);
}
return true;
}
return false;
}
bool ClientHandler::GetPrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefPrintInfo& printInfo,

View File

@@ -21,6 +21,8 @@ class ClientHandler : public CefClient,
public CefLoadHandler,
public CefRequestHandler,
public CefDisplayHandler,
public CefFocusHandler,
public CefKeyboardHandler,
public CefPrintHandler,
public CefJSBindingHandler,
public CefDragHandler,
@@ -39,6 +41,10 @@ public:
{ return this; }
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE
{ return this; }
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE
{ return this; }
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE
{ return this; }
virtual CefRefPtr<CefPrintHandler> GetPrintHandler() OVERRIDE
{ return this; }
virtual CefRefPtr<CefJSBindingHandler> GetJSBindingHandler() OVERRIDE
@@ -97,6 +103,18 @@ public:
const CefString& source,
int line) OVERRIDE;
// CefFocusHandler methods.
virtual void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node) OVERRIDE;
// CefKeyboardHandler methods.
virtual bool OnKeyEvent(CefRefPtr<CefBrowser> browser,
KeyEventType type,
int code,
int modifiers,
bool isSystemKey) OVERRIDE;
// CefPrintHandler methods.
virtual bool GetPrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
@@ -192,6 +210,9 @@ protected:
typedef std::map<std::string, CefRefPtr<CefDOMVisitor> > DOMVisitorMap;
DOMVisitorMap m_DOMVisitors;
// True if a form element currently has focus
bool m_bFormElementHasFocus;
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(ClientHandler);
// Include the default locking implementation.