+ // An attempt to implement OnCharHook by calling OnCharHook first;
+ // if this returns TRUE, set continueToDispatch to False
+ // (don't continue processing).
+ // Otherwise set it to True and call OnChar.
+ wxKeyEvent keyEvent(wxEVT_CHAR);
+ if (wxTranslateKeyEvent(keyEvent, dialog, wid, event))
+ {
+ keyEvent.SetEventObject(dialog);
+ keyEvent.SetId(dialog->GetId());
+ keyEvent.SetEventType(wxEVT_CHAR_HOOK);
+ if (dialog->GetEventHandler()->ProcessEvent(keyEvent))
+ {
+ *continueToDispatch = False;
+ return;
+ }
+ else
+ {
+ // For simplicity, OnKeyDown is the same as OnChar
+ // TODO: filter modifier key presses from OnChar
+ keyEvent.SetEventType(wxEVT_KEY_DOWN);
+
+ // Only process OnChar if OnKeyDown didn't swallow it
+ if (!dialog->GetEventHandler()->ProcessEvent (keyEvent))
+ {
+ keyEvent.SetEventType(wxEVT_CHAR);
+ dialog->GetEventHandler()->ProcessEvent(keyEvent);
+ }
+ }
+ }
+ }