// macros
// ----------------------------------------------------------------------------
+BEGIN_EVENT_TABLE(wxButton, wxButtonBase)
+ EVT_CHAR_HOOK(wxButton::OnCharHook)
+END_EVENT_TABLE()
+
// ============================================================================
// implementation
// ============================================================================
// set this button as being currently default
void wxButton::SetTmpDefault()
{
- wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(GetParent());
+ wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(this);
if ( !tlw )
return;
// unset this button as currently default, it may still stay permanent default
void wxButton::UnsetTmpDefault()
{
- wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(GetParent());
+ wxTopLevelWindow * const tlw = GetTLWParentIfNotBeingDeleted(this);
if ( !tlw )
return;
// event/message handlers
// ----------------------------------------------------------------------------
+void wxButton::OnCharHook(wxKeyEvent& event)
+{
+ // We want to ensure that the button always processes Enter key events
+ // itself, even if it's inside some control that normally takes over them
+ // (this happens when the button is part of an in-place editor control for
+ // example).
+ if ( event.GetKeyCode() == WXK_RETURN )
+ {
+ // We should ensure that subsequent key events are still generated even
+ // if we did handle EVT_CHAR_HOOK (normally this would suppress their
+ // generation).
+ event.DoAllowNextEvent();
+ }
+ else
+ {
+ event.Skip();
+ }
+}
+
bool wxButton::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
{
bool processed = false;