#include "wx/window.h"
#include "wx/frame.h"
+#include "wx/button.h"
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/gdicmn.h"
short keychar ;
keychar = short(ev->message & charCodeMask);
keycode = short(ev->message & keyCodeMask) >> 8 ;
-
+ long keyval = wxMacTranslateKey(keychar, keycode) ;
+ bool handled = false ;
wxWindow* focus = wxWindow::FindFocus() ;
if ( focus )
{
- long keyval = wxMacTranslateKey(keychar, keycode) ;
wxKeyEvent event(wxEVT_KEY_DOWN);
event.m_shiftDown = ev->modifiers & shiftKey;
event.m_y = ev->where.v;
event.m_timeStamp = ev->when;
event.SetEventObject(focus);
- bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
+ handled = focus->GetEventHandler()->ProcessEvent( event ) ;
if ( !handled )
{
#if wxUSE_ACCEL
new_event.SetCurrentFocus( focus );
handled = focus->GetEventHandler()->ProcessEvent( new_event );
}
+ }
+ if ( !handled )
+ {
+ // if window is not having a focus still testing for default enter or cancel
+ // TODO add the UMA version for ActiveNonFloatingWindow
+ focus = wxFindWinFromMacWindow( FrontWindow() ) ;
+ if ( focus )
+ {
+ if ( keyval == WXK_RETURN )
+ {
+ wxButton *def = wxDynamicCast(focus->GetDefaultItem(),
+ wxButton);
+ if ( def && def->IsEnabled() )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
+ event.SetEventObject(def);
+ def->Command(event);
+ return ;
+ }
+ }
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
- if ( (!handled) &&
- (keyval == '.' && event.ControlDown() ) )
+ else if (keyval == WXK_ESCAPE || (keyval == '.' && ev->modifiers & cmdKey ) )
{
- wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
- new_event.SetEventObject( focus );
- handled = focus->GetEventHandler()->ProcessEvent( new_event );
+ wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
+ new_event.SetEventObject( focus );
+ handled = focus->GetEventHandler()->ProcessEvent( new_event );
}
+ }
}
}
}