Side mouse buttons for history navigation

1 view
Skip to first unread message

matthew....@gmail.com

unread,
Sep 25, 2013, 5:48:19 PM9/25/13
to node-...@googlegroups.com
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

Anatoly Pashin

unread,
Sep 25, 2013, 6:50:04 PM9/25/13
to node-...@googlegroups.com
This events is not propaganated to javascript. You can view all available events in developer tools:
Встроенное изображение 1

The way you can do this in nw is similar, but I can't advice you anything.

--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Пашин Анатолий,
эникейщик.
image.png
Reply all
Reply to author
Forward
0 new messages