Then elsewhere I try to simulate a key event as follows:
ke = MyKeyEvent(self.field1, 49)
self.field1.GetEventHandler().AddPendingEvent(ke)
where self.field1 is a custom wxTextCtrl. I also tried:
self.field1.GetEventHandler().ProcessEvent(ke),
self.field1.ProcessEvent(ke),
self.field1.AddPendingEvent(ke),
and
ke.Skip(),
but the text control never seems to see this "simulated" key event.
Is there any way to do this, or should I give up on testing derived
controls in this fashion? Thanks.
···
=====
Donnal Walter
Arkansas Children's Hospital
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com
Then elsewhere I try to simulate a key event as follows:
ke = MyKeyEvent(self.field1, 49)
self.field1.GetEventHandler().AddPendingEvent(ke)
where self.field1 is a custom wxTextCtrl. I also tried:
self.field1.GetEventHandler().ProcessEvent(ke),
self.field1.ProcessEvent(ke),
self.field1.AddPendingEvent(ke),
and
ke.Skip(),
but the text control never seems to see this "simulated" key event.
Is there any way to do this, or should I give up on testing derived
controls in this fashion? Thanks.
Then elsewhere I try to simulate a key event as follows:
ke = MyKeyEvent(self.field1, 49)
self.field1.GetEventHandler().AddPendingEvent(ke)
where self.field1 is a custom wxTextCtrl. I also tried:
self.field1.GetEventHandler().ProcessEvent(ke),
self.field1.ProcessEvent(ke),
self.field1.AddPendingEvent(ke),
and
ke.Skip(),
but the text control never seems to see this "simulated" key event.
Is there any way to do this,
Yes it should work. I fiddled around in the demo a bit and this works for me:
ke = wxKeyEvent(wxEVT_CHAR)
ke.SetEventObject(self.tc1)
ke.SetId(self.tc1.GetId())
ke.m_keyCode = ord('A')
self.tc1.GetEventHandler().ProcessEvent(ke)
or should I give up on testing derived
controls in this fashion? Thanks.
As long as you are aware that this will only cause the event to be delivered to your handler and it won't cause the char to actually be added to the native widget then you should be okay.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!