On 17/03/11 20.34, Octavian Rasnita wrote: Hi,
I thought that if I define an EVT_CHAR event handler for a form is enough, and that event will appear each time a key is pressed, no matter which control on that form has the focus:
<snip>
But if there are some controls on the form and one of them has the focus in a certain moment, the function OnChar is not called. If I comment out all the controls definitions and the form remains empty, that function is called. I've seen that if I define an event handler for each controls on the form, the event handler works when a certain control has the focus: EVT_CHAR($self->{TextField}, \&OnChar); But... is this the way it should be? Isn't there something wrong? I found a little strange that the form's event handler EVT_CHAR is not working if there are controls on the form and that I need to define this event handler for all the form elements.
wxKeyEvent does not derive from wxCommandEvent, so it is only sent to the control generating the event (like wxMouseEvents), hence this is the expected behavior.
Regards, Mattia