Keydown in MFC

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.

Keydown in MFC

Postby tom » Thu Nov 05, 2009 10:15 am

Hello and wonder if you can help

I am trying to add a WM_KEYDOWN to my CEF class. This is so I can make F5 refresh of the page. The problem is that the Chromium doesn't pass the event WM_KEYDOWN back. So what event would key down be?

Tom
tom
Techie
 
Posts: 12
Joined: Thu Nov 05, 2009 10:05 am

Re: Keydown in MFC

Postby magreenblatt » Thu Nov 05, 2009 1:13 pm

Hi Tom,

I haven't tried this, but from reading the Chromium sources I believe you will need to do something like the following:

1. Modify webwidget_host.cc WebWidgetHost::WndProc to store the key press from key-related Windows messages. This is basically what Chromium does in browser/renderer_host/render_widget_host_view_win.cc RenderWidgetHostViewWin::OnKeyEvent().

2. Implement the handleCurrentKeyboardEvent() method from WebKit::WebViewClient in browser_webview_delegate to be notified if WebKit did not handle the key press.

Regards,
Marshall
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Keydown in MFC

Postby magreenblatt » Thu Nov 05, 2009 1:21 pm

An alternative approach might be intercepting the keyboard events by overriding OnWndMsg() or PreTranslateMessage() in the MFC window class that is the parent of the CEF browser window. I'm not sure whether that will work in your particular case though.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Keydown in MFC

Postby ctp » Wed Nov 11, 2009 4:48 am

I have implemented the first option, which seems to work. I have a patch here as the changes may be useful; there does not seem to be an open issue for this, so should one be created to attach it to?

Thanks.
ctp
Newbie
 
Posts: 1
Joined: Wed Nov 11, 2009 4:40 am

Re: Keydown in MFC

Postby magreenblatt » Wed Nov 11, 2009 9:38 am

Cool, I'm glad to hear it worked for you. Please create an issue and attach your patch. :-)

Thanks,
Marshall
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 49 guests