added default return and escape/command-period handling for dialogs
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12863 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1406,11 +1406,11 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
|||||||
short keychar ;
|
short keychar ;
|
||||||
keychar = short(ev->message & charCodeMask);
|
keychar = short(ev->message & charCodeMask);
|
||||||
keycode = short(ev->message & keyCodeMask) >> 8 ;
|
keycode = short(ev->message & keyCodeMask) >> 8 ;
|
||||||
|
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
||||||
|
bool handled = false ;
|
||||||
wxWindow* focus = wxWindow::FindFocus() ;
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
if ( focus )
|
if ( focus )
|
||||||
{
|
{
|
||||||
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
|
||||||
|
|
||||||
wxKeyEvent event(wxEVT_KEY_DOWN);
|
wxKeyEvent event(wxEVT_KEY_DOWN);
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
event.m_shiftDown = ev->modifiers & shiftKey;
|
||||||
@@ -1422,7 +1422,7 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
|||||||
event.m_y = ev->where.v;
|
event.m_y = ev->where.v;
|
||||||
event.m_timeStamp = ev->when;
|
event.m_timeStamp = ev->when;
|
||||||
event.SetEventObject(focus);
|
event.SetEventObject(focus);
|
||||||
bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
if ( !handled )
|
if ( !handled )
|
||||||
{
|
{
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
@@ -1475,14 +1475,34 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
|||||||
new_event.SetCurrentFocus( focus );
|
new_event.SetCurrentFocus( focus );
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
}
|
}
|
||||||
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
|
}
|
||||||
if ( (!handled) &&
|
if ( !handled )
|
||||||
(keyval == '.' && event.ControlDown() ) )
|
{
|
||||||
|
// 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 )
|
||||||
{
|
{
|
||||||
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
wxButton *def = wxDynamicCast(focus->GetDefaultItem(),
|
||||||
new_event.SetEventObject( focus );
|
wxButton);
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
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) */
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1406,11 +1406,11 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
|||||||
short keychar ;
|
short keychar ;
|
||||||
keychar = short(ev->message & charCodeMask);
|
keychar = short(ev->message & charCodeMask);
|
||||||
keycode = short(ev->message & keyCodeMask) >> 8 ;
|
keycode = short(ev->message & keyCodeMask) >> 8 ;
|
||||||
|
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
||||||
|
bool handled = false ;
|
||||||
wxWindow* focus = wxWindow::FindFocus() ;
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
if ( focus )
|
if ( focus )
|
||||||
{
|
{
|
||||||
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
|
||||||
|
|
||||||
wxKeyEvent event(wxEVT_KEY_DOWN);
|
wxKeyEvent event(wxEVT_KEY_DOWN);
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
event.m_shiftDown = ev->modifiers & shiftKey;
|
||||||
@@ -1422,7 +1422,7 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
|||||||
event.m_y = ev->where.v;
|
event.m_y = ev->where.v;
|
||||||
event.m_timeStamp = ev->when;
|
event.m_timeStamp = ev->when;
|
||||||
event.SetEventObject(focus);
|
event.SetEventObject(focus);
|
||||||
bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
if ( !handled )
|
if ( !handled )
|
||||||
{
|
{
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
@@ -1475,14 +1475,34 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev )
|
|||||||
new_event.SetCurrentFocus( focus );
|
new_event.SetCurrentFocus( focus );
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
}
|
}
|
||||||
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
|
}
|
||||||
if ( (!handled) &&
|
if ( !handled )
|
||||||
(keyval == '.' && event.ControlDown() ) )
|
{
|
||||||
|
// 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 )
|
||||||
{
|
{
|
||||||
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
wxButton *def = wxDynamicCast(focus->GetDefaultItem(),
|
||||||
new_event.SetEventObject( focus );
|
wxButton);
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
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) */
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user