I am trying to migrate a CEF based application of mine over to using node-webkit, and I can't figure out how to use the side mouse buttons for history navigation within node-webkit. Is there a way to bind these events within javascript or to enable the default behavior within node-webkit?
In my CEF app, I had to add the following code to make it work.
1) Added a hook within cefclient_win.cpp
DWORD threadId = GetWindowThreadProcessId(hwnd, NULL);
HHOOK hook = SetWindowsHookEx(WH_KEYBOARD, BrowserKeyboardHook, NULL, threadId);
hook = SetWindowsHookEx(WH_MOUSE, BrowserMouseHook, NULL, threadId);
2) Where my callback is defined as follows
LRESULT CALLBACK BrowserMouseHook(int nCode, WPARAM wp, LPARAM lp)
{
MOUSEHOOKSTRUCTEX* p = (MOUSEHOOKSTRUCTEX*)lp;
if (wp == WM_XBUTTONUP) {
CefRefPtr<CefBrowser> browser;
if (g_handler.get()) {
browser = g_handler->GetBrowser();
int mouseData = GET_XBUTTON_WPARAM(p->mouseData);
if (mouseData & XBUTTON1) {
if (browser.get())
browser->GoBack();
return 1;
}
if (mouseData & XBUTTON2) {
if (browser.get())
browser->GoForward();
return 1;
}
}
}
return CallNextHookEx(NULL, nCode, wp, lp);
}
Thanks,
Matt