Help with arrow keys / tabs in browser in CDialog

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Help with arrow keys / tabs in browser in CDialog

Postby hyzerfool » Mon Oct 03, 2016 3:37 pm

We've run into the problem where CEF's not handling tab or arrow keys properly. We're using CEF in a windows MFC app containing multiple browsers.

I found the posts about using an external message pump fixing it, so I upgraded to 3.2785.1482 and set it to use external_message_pump=true. I copied main_message_loop_external_pump.cc/h and main_message_loop_external_pump_win from cefclient, but things work just like they did before. That is, except for the tabs/arrow keys, things work correctly, but tabs/arrow keys still don't work.

Does anyone have any ideas? Am I right that it's expected that 2785 w/ external message pump is supposed to fix this?

Help?
Last edited by hyzerfool on Tue Oct 04, 2016 12:44 pm, edited 1 time in total.
hyzerfool
Techie
 
Posts: 23
Joined: Wed May 13, 2015 2:37 pm

Re: Help with arrow keys / tabs and external_message_pump

Postby magreenblatt » Mon Oct 03, 2016 3:52 pm

What Windows version? Does the problem reproduce in cefclient running with `--external-message-pump`?
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Help with arrow keys / tabs and external_message_pump

Postby hyzerfool » Mon Oct 03, 2016 5:51 pm

I'm running Windows 10-64 bit, but I don't think it matters to my issue. I just tried it on Windows 7-64 and it acted the same (and the general problem of tabs/arrows we've has reports of from multiple windows versions).

cefclient works correctly whether using --external-message-pump or not.

My understanding was that our issue is because I was calling CefDoMessageLoopWork in PumpMessage as opposed to calling CefRunMessageLoop. Ahh, though I guess in cefclient w/ the external pump it calls CefDoMessageLoopWork.

My brain hurts. I need pizza.
hyzerfool
Techie
 
Posts: 23
Joined: Wed May 13, 2015 2:37 pm

Help with arrow keys / tabs in browser in CDialog

Postby hyzerfool » Tue Oct 04, 2016 12:43 pm

I'm trying to work through this and figure out where the break is, since the bug doesn't show up in the samples.

I'm now creating a straight CefBrowser (as opposed to my specialized class with layers of extra stuff in it), and I'm using SimpleHandler from cefsimple as the handler, but I still get the same behavior (specifically, the arrow keys don't work when I click in a text edit box, type something, and try to use the arrow key to move around in that edit).

I've tried that both on my own html and by going to google.com.
I do get the keypress events for the arrow keys when I peek in PreTranslateMessage.

The browser I'm creating is going in a dialog, but --
-- aha! If I create the browser in a CView rather than a CDialog, then the arrow keys work correctly.

I've tried to change the subject of this thread to reflect that this is not actually an external message pump issue.

I'll keep working on it, but any insights on what sorts of problems might be causing this would be very much appreciated.
hyzerfool
Techie
 
Posts: 23
Joined: Wed May 13, 2015 2:37 pm

Re: Help with arrow keys / tabs in browser in CDialog

Postby magreenblatt » Tue Oct 04, 2016 1:42 pm

magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Re: Help with arrow keys / tabs in browser in CDialog

Postby hyzerfool » Tue Oct 04, 2016 8:59 pm

Finally got this working, with some help from this thread:
https://magpcss.org/ceforum/viewtopic.php?f=6&t=11383

I put this code in OnInitDialog:
Code: Select all
   HWND b_hwnd = m_pBrowserCtrl->GetBrowser ()->GetHost()->GetWindowHandle();
   HWND hwnd = ::GetWindow(b_hwnd, GW_CHILD);
   bool bRet = SetWindowSubclass (hwnd, &mySubClassProc, 1, 0);


and this in mySubClassProc:
Code: Select all
LRESULT CALLBACK mySubClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
    switch(uMsg)
    {
      case WM_GETDLGCODE:
         return DLGC_WANTALLKEYS;

        case WM_NCDESTROY:
            RemoveWindowSubclass(hWnd, &mySubClassProc, 1);
            break;
    }

    return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}


And it seems to be working. Note that it did NOT work when I subclassed the HWND I passed in to CreateBrowserSync. Looking at it now I guess that make sense as I'm using CefWindowInfo::SetAsChild when I create the browser.

Also, since I started this thinking the issue was the message pump, I should note that this fixes things whether using the external message pump or calling CefDoMessageLoopWork from PumpMessage.

Thanks for the help!
hyzerfool
Techie
 
Posts: 23
Joined: Wed May 13, 2015 2:37 pm

Re: Help with arrow keys / tabs in browser in CDialog

Postby amaitland » Sun Oct 09, 2016 10:05 pm

magreenblatt wrote:This is likely relevant: https://social.msdn.microsoft.com/Forum ... m=vcmfcatl


Thanks Marshall. Had a similar problem in .Net WinForms.

For reference
http://stackoverflow.com/questions/1646 ... 92#5606692

Some key presses, such as the TAB, RETURN, ESC, and arrow keys, are typically ignored by some controls because they are not considered input key presses.


https://msdn.microsoft.com/en-us/librar ... x#Anchor_1
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 57 guests

cron