Kirix Support Forums

wxWebControl is eating keyboard events

Please post all general questions, comments, bug reports, and any other wxWebConnect feedback here.

wxWebControl is eating keyboard events

Postby gkiagia on Fri Aug 13, 2010 9:18 am

Hello,

I have an application which uses some custom keyboard event handling, implemented by intercepting events from wxApp::FilterEvent() and passing them to an input manager class. I have now started using wxWebControl to show some generated web content inside the application, but I experience a problem with the keyboard event handling. The problem is that when the browser control has the focus, many keyboard events are silently "eaten", especially the much needed wxEVT_KEY_UP events.

To be more precise, I need to handle the arrow keys in my application. When the browser control doesn't have the focus, pressing and releasing an arrow key generates two events: one of type wxEVT_CHAR_HOOK and a second one of type wxEVT_KEY_UP. But when the browser control has the focus, it generates only one wxEVT_CHAR_HOOK event and the KEY_UP event is silently "eaten". This causes trouble to my input manager, which uses KEY_UP events to discard events that are generated by keyboard repeat (pressing a key for a long time will generate many CHAR_HOOK events but only one KEY_UP event)

I have tried to work this around by commenting out all the code that sets focus to the browser control in webcontrol.cpp and the situation is a bit better, however there is still the problem that when I click on the browser control, the control gets the focus even if I have commented out the code that sets the focus on mousedown (at webcontrol.cpp line 845).

Any ideas on how to fix this?

Regards,
George
gkiagia
Registered User
 
Posts: 1
Joined: Fri Aug 13, 2010 8:57 am

Re: wxWebControl is eating keyboard events

Postby jonmmorgan on Mon Aug 16, 2010 9:46 am

This will be a result of the Mozilla component being embedded having a completely different event handling process and windowing system. However, it is possible to change it to get the key events from the web control. An example can be found at http://github.com/jonmmorgan/wxwebconne ... a1365cdfa4. It's worth noting that there is still a need to translate from Mozilla key codes to wxWidgets key codes, which I have not done yet (so it's probably really only reliable for alphabetic characters). In particular, I know that the arrow keys do not work. All of the Mozilla key codes are in the header, and you could do a mapping if you wanted to (DOM_VK_RIGHT and DOM_VK_LEFT are probably the key codes you care about, and they probably map to WXK_UP and WXK_DOWN).
jonmmorgan
Registered User
 
Posts: 94
Joined: Fri May 14, 2010 9:48 am

Re: wxWebControl is eating keyboard events

Postby jonmmorgan on Fri Nov 26, 2010 11:53 pm

The mapping of keyboard keycodes is now done at https://github.com/jonmmorgan/wxwebconn ... 3b49cf0d79.
jonmmorgan
Registered User
 
Posts: 94
Joined: Fri May 14, 2010 9:48 am

Return to wxWebConnect Questions, Thoughts & Feedback