I'm using Visual Studio 2017, C++ / MFC.
When clicking the, "Back", button on a mouse:
In CEF 3.2840.1518, is handled by CMainFrame::OnAppCommand in my MFC app. We handle it to change which view is active and the CEF browser does not receive the event. This is what we want to happen.
In CEF 3.3578.1863, CMainFrame::OnAppCommand does not receive the event, so the browser catches it and navigates back in history. We do not want this.
1) I used SetWindowSubclass on the browser's HWND and catch the event (WM_PARENTNOTIFY with WM_XBUTTONDOWN as LoWord), which works for letting me change the active view, but the CEF browser is still handling the message and navigating back in history, despite me returning 0 from our handler (which I think for WM_PARENTNOTIFY should say I handled things).
2) I tried to trap this in OnBeforeBrowse, using request->GetTransitionType () & TT_FORWARD_BACK_FLAG. This does work for catching the Forward button event from a mouse, but OnBeforeBrowse is not called when using the back button. This is usually navigating back to an about:blank, which DOES seem to make a difference. I ran a test where "Back" reverted the browser to a previously loaded html page, as opposed to about:blank, and then OnBeforeBrowse WAS called.
3) I found some old threads that suggest trapping it in OnBeforeNavigation, but that's no longer supported. My understanding is that the functionality is now handled by OnBeforeBrowse.
4) I tried stopping it in OnLoadStart (by calling browser->StopLoad ()), but it seems to be too late at that point.
Ideally, I'd like this to be handled by OnAppCommand, but I'm also ok hacking my way around it with SetWindowSubClass, as long as I can stop the CEF browser from navigating forward / back in response to the mouse click.
Help?
I guess I can try initially opening the browser on an empty html page, but that's getting pretty hack-y at that point. I will if I have to, but...