[wx 2.6.x, arm/x86, gnu] Creating my own wxKeyEvents and Accelerator events

Richard Harvey Chapman hchapman-wx-users at 3gfp.com
Tue Apr 3 06:07:53 PDT 2007


On Mar 28, 2007, at 5:55 AM, Vadim Zeitlin wrote:

> On Wed, 28 Mar 2007 04:35:20 -0400 Richard Harvey Chapman <hchapman- 
> wx-users at 3gfp.com> wrote:
>
> RHC> I have a custom keypad/keyboard with driver. I can get the events
> RHC> (via SIGIO) for the keypad in my application, but I'd like to get
> RHC> wxWidgets to process them as though they came from the normal
> RHC> keyboard. I don't think wxPostEvent will do this for me,
>
>  wxPostEvent would be enough if you only wanted to process the key  
> events
> in your own code but it wouldn't work with native controls (e.g.
> wxTextCtrl).

wxPostEvent did work, thank you. I modified my code to tell the  
difference (Accel events have no object, wxPostEvents must). I didn't  
realize until last night that the accel events are generated by wx.

Part of my confusion was how to create my own key events which would  
behave like regular keyboard key events.

Below are listed all of the events (that I know of) generated by a  
single key press followed by the table of skipped events. I think it  
might be useful to add this info to the wx documentation.

Widget Key Down
Widget Accel
Widget Char
Parent-Tree Accel
Widget Key Up

                ||               Events Received By App
event.Skip()   ||---------------------------------------------------
issued         ||      |         |         |                |      |
during...      || Down |  Accel  |  Char   |  Accel Parent  |  Up  |
====================================================================
Down           ||      | skipped | skipped |   skipped      |      |
Accel          ||      |         | skipped |   skipped      |      |
Char           ||      |         |         |   skipped      |      |
Accel Parent   ||      |         |         | skipped (tree) |      |
Up             ||      |         |         |                |      |

I'd like to receive a key press/release from my driver code, perform  
step X, and have the normal behavior above.

How do I generate a Key Down/Char/Up event? The documentation  
mentions wxKeyEvent(wxEVENT_CHAR | wxEVENT_CHAR_HOOK) but does not  
say what the two options mean or elaborate further.

>  If you're using wxGTK I think you should look into generating X11  
> events.
> Maybe gdk_display_put_event() can help you.

This may solve another problem of mine, there is no way via code to  
activate a combo box's drop down list. You can hit 'Space' which GTK+  
will intercept or click with a mouse, but there is no way (that I can  
tell) to activate the list via code. This is important for handheld  
devices with no mice or keyboards. I think I may be able to use  
the ...put_event() function to perhaps send the 'Space' event.

Is there a uniform way to get the underlying GTK+ widget for any wx  
widget?

Thank you,

R.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070403/b9c79f63/PGP.pgp


More information about the wx-users mailing list