On Thu, 11 May 2023 02:34:03 -0700 (PDT) Tobias T wrote:
TT> I would like to add support to handle accelerator key press handling to the
TT> Edge backend.
This would be nice and welcome, of course!
TT> Currently key presses are just handled inside the web view and there is no
TT> way to get them with wxWidgets key events etc.
TT>
TT> There is an API to handle accelerator keys documented here
TT> <
https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.1774.30#add_acceleratorkeypressed>
TT> .
TT>
TT> Handling is easy enough but it would obviously nice to not create an extra
TT> web view edge specic event type.
TT> However I'm not sure if this should how to implement this, my ideas would
TT> be:
TT>
TT> 1. simply trigger key up / down events. Which is would work but would of
TT> course only be triggered for accelerator keys (which would make it
TT> different to other key events).
TT> 2. Another option would be to integrate somehow into the the accelerator
TT> table so that menu shortcuts and other added keyboard shortcuts would just
TT> work in the webview (there I would need some pointers how that could be
TT> implemented).
TT> 3. A specifc event just used in the webview
TT>
TT> I think option 2 would be the cleanest as it would require any extra user
TT> code.
I agree that as long as it only works for the accelerators, (2) seems to
be the best option. Accelerators generate wxCommandEvents, so integrating
them would mean finding the wxAcceleratorEntry matching the pressed key and
generating the event with its ID.
The main problem I see here is that wxMSW uses native implementation for
wxAcceleratorTable, which relies on Win32 TranslateAccelerator() to work,
so you'd have to create a dummy MSG describing the key press to pass to it.
Would it be possible to do this with the information provided by Edge API?
Good luck!
VZ