routing key events to new app routine
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15912 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
215
src/mac/app.cpp
215
src/mac/app.cpp
@@ -1031,7 +1031,7 @@ bool wxApp::OnInit()
|
|||||||
if ( ! wxAppBase::OnInit() )
|
if ( ! wxAppBase::OnInit() )
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if 0 // TARGET_CARBON
|
||||||
static const EventTypeSpec eventList[] =
|
static const EventTypeSpec eventList[] =
|
||||||
{
|
{
|
||||||
{ kEventClassKeyboard, kEventRawKeyDown } ,
|
{ kEventClassKeyboard, kEventRawKeyDown } ,
|
||||||
@@ -1718,7 +1718,7 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
|
|||||||
if ( HiWord( menuresult ) )
|
if ( HiWord( menuresult ) )
|
||||||
{
|
{
|
||||||
if ( !s_macIsInModalLoop )
|
if ( !s_macIsInModalLoop )
|
||||||
MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
|
MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1726,96 +1726,102 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
|
|||||||
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 ;
|
||||||
// it is wxWindows Convention to have Ctrl Key Combinations at ASCII char value
|
|
||||||
if ( ev->modifiers & controlKey && keychar >= 0 && keychar < 0x20 )
|
|
||||||
{
|
|
||||||
keychar += 0x40 ;
|
|
||||||
}
|
|
||||||
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
||||||
bool handled = false ;
|
|
||||||
wxWindow* focus = wxWindow::FindFocus() ;
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
if ( focus )
|
|
||||||
{
|
|
||||||
|
|
||||||
wxKeyEvent event(wxEVT_KEY_DOWN);
|
if ( MacSendKeyDownEvent( focus , keyval , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
{
|
||||||
event.m_controlDown = ev->modifiers & controlKey;
|
// has not been handled -> perform default
|
||||||
event.m_altDown = ev->modifiers & optionKey;
|
wxControl* control = wxDynamicCast( focus , wxControl ) ;
|
||||||
event.m_metaDown = ev->modifiers & cmdKey;
|
if ( control && control->GetMacControl() != NULL )
|
||||||
event.m_keyCode = keyval;
|
|
||||||
event.m_x = ev->where.h;
|
|
||||||
event.m_y = ev->where.v;
|
|
||||||
event.m_timeStamp = ev->when;
|
|
||||||
event.SetEventObject(focus);
|
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
|
||||||
if ( handled && event.GetSkipped() )
|
|
||||||
handled = false ;
|
|
||||||
if ( !handled )
|
|
||||||
{
|
{
|
||||||
|
::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey )
|
||||||
|
{
|
||||||
|
bool handled = false ;
|
||||||
|
// it is wxWindows Convention to have Ctrl Key Combinations at ASCII char value
|
||||||
|
if ( modifiers & controlKey && keyval >= 0 && keyval < 0x20 )
|
||||||
|
{
|
||||||
|
keyval += 0x40 ;
|
||||||
|
}
|
||||||
|
wxKeyEvent event(wxEVT_KEY_DOWN);
|
||||||
|
event.m_shiftDown = modifiers & shiftKey;
|
||||||
|
event.m_controlDown = modifiers & controlKey;
|
||||||
|
event.m_altDown = modifiers & optionKey;
|
||||||
|
event.m_metaDown = modifiers & cmdKey;
|
||||||
|
event.m_keyCode = keyval;
|
||||||
|
|
||||||
|
event.m_x = wherex;
|
||||||
|
event.m_y = wherey;
|
||||||
|
event.m_timeStamp = when;
|
||||||
|
event.SetEventObject(focus);
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
if ( handled && event.GetSkipped() )
|
||||||
|
handled = false ;
|
||||||
|
if ( !handled )
|
||||||
|
{
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
wxWindow *ancestor = focus;
|
wxWindow *ancestor = focus;
|
||||||
while (ancestor)
|
while (ancestor)
|
||||||
{
|
|
||||||
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
|
||||||
if (command != -1)
|
|
||||||
{
|
|
||||||
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
|
||||||
handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (ancestor->IsTopLevel())
|
|
||||||
break;
|
|
||||||
ancestor = ancestor->GetParent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // wxUSE_ACCEL
|
|
||||||
}
|
|
||||||
if (!handled)
|
|
||||||
{
|
{
|
||||||
wxKeyEvent event(wxEVT_CHAR);
|
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
if (command != -1)
|
||||||
event.m_controlDown = ev->modifiers & controlKey;
|
{
|
||||||
event.m_altDown = ev->modifiers & optionKey;
|
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
||||||
event.m_metaDown = ev->modifiers & cmdKey;
|
handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
|
||||||
event.m_keyCode = keyval;
|
break;
|
||||||
event.m_x = ev->where.h;
|
}
|
||||||
event.m_y = ev->where.v;
|
if (ancestor->IsTopLevel())
|
||||||
event.m_timeStamp = ev->when;
|
break;
|
||||||
event.SetEventObject(focus);
|
ancestor = ancestor->GetParent();
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
|
||||||
if ( handled && event.GetSkipped() )
|
|
||||||
handled = false ;
|
|
||||||
}
|
}
|
||||||
if ( !handled &&
|
}
|
||||||
(keyval == WXK_TAB) &&
|
#endif // wxUSE_ACCEL
|
||||||
|
}
|
||||||
|
if (!handled)
|
||||||
|
{
|
||||||
|
event.Skip( FALSE ) ;
|
||||||
|
event.SetEventType( wxEVT_CHAR ) ;
|
||||||
|
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
if ( handled && event.GetSkipped() )
|
||||||
|
handled = false ;
|
||||||
|
}
|
||||||
|
if ( !handled &&
|
||||||
|
(keyval == WXK_TAB) &&
|
||||||
// CS: copied the change below from wxGTK
|
// CS: copied the change below from wxGTK
|
||||||
// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here the control may
|
// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here the control may
|
||||||
// have this style, yet choose not to process this particular TAB in which
|
// have this style, yet choose not to process this particular TAB in which
|
||||||
// case TAB must still work as a navigational character
|
// case TAB must still work as a navigational character
|
||||||
#if 0
|
#if 0
|
||||||
(!focus->HasFlag(wxTE_PROCESS_TAB)) &&
|
(!focus->HasFlag(wxTE_PROCESS_TAB)) &&
|
||||||
#endif
|
#endif
|
||||||
(focus->GetParent()) &&
|
(focus->GetParent()) &&
|
||||||
(focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
(focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent new_event;
|
wxNavigationKeyEvent new_event;
|
||||||
new_event.SetEventObject( focus );
|
new_event.SetEventObject( focus );
|
||||||
new_event.SetDirection( !event.ShiftDown() );
|
new_event.SetDirection( !event.ShiftDown() );
|
||||||
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
new_event.SetWindowChange( event.ControlDown() );
|
new_event.SetWindowChange( event.ControlDown() );
|
||||||
new_event.SetCurrentFocus( focus );
|
new_event.SetCurrentFocus( focus );
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
if ( handled && new_event.GetSkipped() )
|
if ( handled && new_event.GetSkipped() )
|
||||||
handled = false ;
|
handled = false ;
|
||||||
}
|
}
|
||||||
}
|
// backdoor handler for default return and command escape
|
||||||
if ( !handled )
|
if ( !handled && (!focus->IsKindOf(CLASSINFO(wxControl) ) || !focus->MacCanFocus() ) )
|
||||||
{
|
{
|
||||||
// if window is not having a focus still testing for default enter or cancel
|
// if window is not having a focus still testing for default enter or cancel
|
||||||
// TODO add the UMA version for ActiveNonFloatingWindow
|
// TODO add the UMA version for ActiveNonFloatingWindow
|
||||||
focus = wxFindWinFromMacWindow( FrontWindow() ) ;
|
wxWindow* focus = wxFindWinFromMacWindow( FrontWindow() ) ;
|
||||||
if ( focus )
|
if ( focus )
|
||||||
{
|
{
|
||||||
if ( keyval == WXK_RETURN )
|
if ( keyval == WXK_RETURN )
|
||||||
@@ -1827,21 +1833,22 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
|
|||||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
|
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
|
||||||
event.SetEventObject(def);
|
event.SetEventObject(def);
|
||||||
def->Command(event);
|
def->Command(event);
|
||||||
return ;
|
return true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
|
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
|
||||||
else if (keyval == WXK_ESCAPE || (keyval == '.' && ev->modifiers & cmdKey ) )
|
else if (keyval == WXK_ESCAPE || (keyval == '.' && modifiers & cmdKey ) )
|
||||||
{
|
{
|
||||||
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
||||||
new_event.SetEventObject( focus );
|
new_event.SetEventObject( focus );
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return handled ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
|
void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
|
||||||
{
|
{
|
||||||
EventRecord* ev = (EventRecord*) evr ;
|
EventRecord* ev = (EventRecord*) evr ;
|
||||||
@@ -1857,27 +1864,39 @@ void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
|
|||||||
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) ;
|
||||||
|
|
||||||
wxWindow* focus = wxWindow::FindFocus() ;
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
if ( focus )
|
bool handled = MacSendKeyUpEvent( focus , keyval , ev->modifiers , ev->when , ev->where.h , ev->where.v ) ;
|
||||||
{
|
// we don't have to do anything under classic here
|
||||||
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
|
||||||
|
|
||||||
wxKeyEvent event(wxEVT_KEY_UP);
|
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
|
||||||
event.m_controlDown = ev->modifiers & controlKey;
|
|
||||||
event.m_altDown = ev->modifiers & optionKey;
|
|
||||||
event.m_metaDown = ev->modifiers & cmdKey;
|
|
||||||
event.m_keyCode = keyval;
|
|
||||||
event.m_x = ev->where.h;
|
|
||||||
event.m_y = ev->where.v;
|
|
||||||
event.m_timeStamp = ev->when;
|
|
||||||
event.SetEventObject(focus);
|
|
||||||
bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey )
|
||||||
|
{
|
||||||
|
bool handled = false ;
|
||||||
|
// it is wxWindows Convention to have Ctrl Key Combinations at ASCII char value
|
||||||
|
if ( modifiers & controlKey && keyval >= 0 && keyval < 0x20 )
|
||||||
|
{
|
||||||
|
keyval += 0x40 ;
|
||||||
|
}
|
||||||
|
if ( focus )
|
||||||
|
{
|
||||||
|
wxKeyEvent event(wxEVT_KEY_UP);
|
||||||
|
event.m_shiftDown = modifiers & shiftKey;
|
||||||
|
event.m_controlDown = modifiers & controlKey;
|
||||||
|
event.m_altDown = modifiers & optionKey;
|
||||||
|
event.m_metaDown = modifiers & cmdKey;
|
||||||
|
event.m_keyCode = keyval;
|
||||||
|
|
||||||
|
event.m_x = wherex;
|
||||||
|
event.m_y = wherey;
|
||||||
|
event.m_timeStamp = when;
|
||||||
|
event.SetEventObject(focus);
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
}
|
||||||
|
return handled ;
|
||||||
|
}
|
||||||
void wxApp::MacHandleActivateEvent( WXEVENTREF evr )
|
void wxApp::MacHandleActivateEvent( WXEVENTREF evr )
|
||||||
{
|
{
|
||||||
EventRecord* ev = (EventRecord*) evr ;
|
EventRecord* ev = (EventRecord*) evr ;
|
||||||
|
@@ -1031,7 +1031,7 @@ bool wxApp::OnInit()
|
|||||||
if ( ! wxAppBase::OnInit() )
|
if ( ! wxAppBase::OnInit() )
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if 0 // TARGET_CARBON
|
||||||
static const EventTypeSpec eventList[] =
|
static const EventTypeSpec eventList[] =
|
||||||
{
|
{
|
||||||
{ kEventClassKeyboard, kEventRawKeyDown } ,
|
{ kEventClassKeyboard, kEventRawKeyDown } ,
|
||||||
@@ -1718,7 +1718,7 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
|
|||||||
if ( HiWord( menuresult ) )
|
if ( HiWord( menuresult ) )
|
||||||
{
|
{
|
||||||
if ( !s_macIsInModalLoop )
|
if ( !s_macIsInModalLoop )
|
||||||
MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
|
MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1726,96 +1726,102 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
|
|||||||
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 ;
|
||||||
// it is wxWindows Convention to have Ctrl Key Combinations at ASCII char value
|
|
||||||
if ( ev->modifiers & controlKey && keychar >= 0 && keychar < 0x20 )
|
|
||||||
{
|
|
||||||
keychar += 0x40 ;
|
|
||||||
}
|
|
||||||
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
||||||
bool handled = false ;
|
|
||||||
wxWindow* focus = wxWindow::FindFocus() ;
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
if ( focus )
|
|
||||||
{
|
|
||||||
|
|
||||||
wxKeyEvent event(wxEVT_KEY_DOWN);
|
if ( MacSendKeyDownEvent( focus , keyval , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
{
|
||||||
event.m_controlDown = ev->modifiers & controlKey;
|
// has not been handled -> perform default
|
||||||
event.m_altDown = ev->modifiers & optionKey;
|
wxControl* control = wxDynamicCast( focus , wxControl ) ;
|
||||||
event.m_metaDown = ev->modifiers & cmdKey;
|
if ( control && control->GetMacControl() != NULL )
|
||||||
event.m_keyCode = keyval;
|
|
||||||
event.m_x = ev->where.h;
|
|
||||||
event.m_y = ev->where.v;
|
|
||||||
event.m_timeStamp = ev->when;
|
|
||||||
event.SetEventObject(focus);
|
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
|
||||||
if ( handled && event.GetSkipped() )
|
|
||||||
handled = false ;
|
|
||||||
if ( !handled )
|
|
||||||
{
|
{
|
||||||
|
::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey )
|
||||||
|
{
|
||||||
|
bool handled = false ;
|
||||||
|
// it is wxWindows Convention to have Ctrl Key Combinations at ASCII char value
|
||||||
|
if ( modifiers & controlKey && keyval >= 0 && keyval < 0x20 )
|
||||||
|
{
|
||||||
|
keyval += 0x40 ;
|
||||||
|
}
|
||||||
|
wxKeyEvent event(wxEVT_KEY_DOWN);
|
||||||
|
event.m_shiftDown = modifiers & shiftKey;
|
||||||
|
event.m_controlDown = modifiers & controlKey;
|
||||||
|
event.m_altDown = modifiers & optionKey;
|
||||||
|
event.m_metaDown = modifiers & cmdKey;
|
||||||
|
event.m_keyCode = keyval;
|
||||||
|
|
||||||
|
event.m_x = wherex;
|
||||||
|
event.m_y = wherey;
|
||||||
|
event.m_timeStamp = when;
|
||||||
|
event.SetEventObject(focus);
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
if ( handled && event.GetSkipped() )
|
||||||
|
handled = false ;
|
||||||
|
if ( !handled )
|
||||||
|
{
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
wxWindow *ancestor = focus;
|
wxWindow *ancestor = focus;
|
||||||
while (ancestor)
|
while (ancestor)
|
||||||
{
|
|
||||||
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
|
||||||
if (command != -1)
|
|
||||||
{
|
|
||||||
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
|
||||||
handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (ancestor->IsTopLevel())
|
|
||||||
break;
|
|
||||||
ancestor = ancestor->GetParent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // wxUSE_ACCEL
|
|
||||||
}
|
|
||||||
if (!handled)
|
|
||||||
{
|
{
|
||||||
wxKeyEvent event(wxEVT_CHAR);
|
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
if (command != -1)
|
||||||
event.m_controlDown = ev->modifiers & controlKey;
|
{
|
||||||
event.m_altDown = ev->modifiers & optionKey;
|
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
||||||
event.m_metaDown = ev->modifiers & cmdKey;
|
handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
|
||||||
event.m_keyCode = keyval;
|
break;
|
||||||
event.m_x = ev->where.h;
|
}
|
||||||
event.m_y = ev->where.v;
|
if (ancestor->IsTopLevel())
|
||||||
event.m_timeStamp = ev->when;
|
break;
|
||||||
event.SetEventObject(focus);
|
ancestor = ancestor->GetParent();
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
|
||||||
if ( handled && event.GetSkipped() )
|
|
||||||
handled = false ;
|
|
||||||
}
|
}
|
||||||
if ( !handled &&
|
}
|
||||||
(keyval == WXK_TAB) &&
|
#endif // wxUSE_ACCEL
|
||||||
|
}
|
||||||
|
if (!handled)
|
||||||
|
{
|
||||||
|
event.Skip( FALSE ) ;
|
||||||
|
event.SetEventType( wxEVT_CHAR ) ;
|
||||||
|
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
if ( handled && event.GetSkipped() )
|
||||||
|
handled = false ;
|
||||||
|
}
|
||||||
|
if ( !handled &&
|
||||||
|
(keyval == WXK_TAB) &&
|
||||||
// CS: copied the change below from wxGTK
|
// CS: copied the change below from wxGTK
|
||||||
// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here the control may
|
// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here the control may
|
||||||
// have this style, yet choose not to process this particular TAB in which
|
// have this style, yet choose not to process this particular TAB in which
|
||||||
// case TAB must still work as a navigational character
|
// case TAB must still work as a navigational character
|
||||||
#if 0
|
#if 0
|
||||||
(!focus->HasFlag(wxTE_PROCESS_TAB)) &&
|
(!focus->HasFlag(wxTE_PROCESS_TAB)) &&
|
||||||
#endif
|
#endif
|
||||||
(focus->GetParent()) &&
|
(focus->GetParent()) &&
|
||||||
(focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
(focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent new_event;
|
wxNavigationKeyEvent new_event;
|
||||||
new_event.SetEventObject( focus );
|
new_event.SetEventObject( focus );
|
||||||
new_event.SetDirection( !event.ShiftDown() );
|
new_event.SetDirection( !event.ShiftDown() );
|
||||||
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
new_event.SetWindowChange( event.ControlDown() );
|
new_event.SetWindowChange( event.ControlDown() );
|
||||||
new_event.SetCurrentFocus( focus );
|
new_event.SetCurrentFocus( focus );
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
if ( handled && new_event.GetSkipped() )
|
if ( handled && new_event.GetSkipped() )
|
||||||
handled = false ;
|
handled = false ;
|
||||||
}
|
}
|
||||||
}
|
// backdoor handler for default return and command escape
|
||||||
if ( !handled )
|
if ( !handled && (!focus->IsKindOf(CLASSINFO(wxControl) ) || !focus->MacCanFocus() ) )
|
||||||
{
|
{
|
||||||
// if window is not having a focus still testing for default enter or cancel
|
// if window is not having a focus still testing for default enter or cancel
|
||||||
// TODO add the UMA version for ActiveNonFloatingWindow
|
// TODO add the UMA version for ActiveNonFloatingWindow
|
||||||
focus = wxFindWinFromMacWindow( FrontWindow() ) ;
|
wxWindow* focus = wxFindWinFromMacWindow( FrontWindow() ) ;
|
||||||
if ( focus )
|
if ( focus )
|
||||||
{
|
{
|
||||||
if ( keyval == WXK_RETURN )
|
if ( keyval == WXK_RETURN )
|
||||||
@@ -1827,21 +1833,22 @@ void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
|
|||||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
|
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
|
||||||
event.SetEventObject(def);
|
event.SetEventObject(def);
|
||||||
def->Command(event);
|
def->Command(event);
|
||||||
return ;
|
return true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
|
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
|
||||||
else if (keyval == WXK_ESCAPE || (keyval == '.' && ev->modifiers & cmdKey ) )
|
else if (keyval == WXK_ESCAPE || (keyval == '.' && modifiers & cmdKey ) )
|
||||||
{
|
{
|
||||||
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
||||||
new_event.SetEventObject( focus );
|
new_event.SetEventObject( focus );
|
||||||
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
handled = focus->GetEventHandler()->ProcessEvent( new_event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return handled ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
|
void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
|
||||||
{
|
{
|
||||||
EventRecord* ev = (EventRecord*) evr ;
|
EventRecord* ev = (EventRecord*) evr ;
|
||||||
@@ -1857,27 +1864,39 @@ void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
|
|||||||
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) ;
|
||||||
|
|
||||||
wxWindow* focus = wxWindow::FindFocus() ;
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
if ( focus )
|
bool handled = MacSendKeyUpEvent( focus , keyval , ev->modifiers , ev->when , ev->where.h , ev->where.v ) ;
|
||||||
{
|
// we don't have to do anything under classic here
|
||||||
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
|
||||||
|
|
||||||
wxKeyEvent event(wxEVT_KEY_UP);
|
|
||||||
event.m_shiftDown = ev->modifiers & shiftKey;
|
|
||||||
event.m_controlDown = ev->modifiers & controlKey;
|
|
||||||
event.m_altDown = ev->modifiers & optionKey;
|
|
||||||
event.m_metaDown = ev->modifiers & cmdKey;
|
|
||||||
event.m_keyCode = keyval;
|
|
||||||
event.m_x = ev->where.h;
|
|
||||||
event.m_y = ev->where.v;
|
|
||||||
event.m_timeStamp = ev->when;
|
|
||||||
event.SetEventObject(focus);
|
|
||||||
bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey )
|
||||||
|
{
|
||||||
|
bool handled = false ;
|
||||||
|
// it is wxWindows Convention to have Ctrl Key Combinations at ASCII char value
|
||||||
|
if ( modifiers & controlKey && keyval >= 0 && keyval < 0x20 )
|
||||||
|
{
|
||||||
|
keyval += 0x40 ;
|
||||||
|
}
|
||||||
|
if ( focus )
|
||||||
|
{
|
||||||
|
wxKeyEvent event(wxEVT_KEY_UP);
|
||||||
|
event.m_shiftDown = modifiers & shiftKey;
|
||||||
|
event.m_controlDown = modifiers & controlKey;
|
||||||
|
event.m_altDown = modifiers & optionKey;
|
||||||
|
event.m_metaDown = modifiers & cmdKey;
|
||||||
|
event.m_keyCode = keyval;
|
||||||
|
|
||||||
|
event.m_x = wherex;
|
||||||
|
event.m_y = wherey;
|
||||||
|
event.m_timeStamp = when;
|
||||||
|
event.SetEventObject(focus);
|
||||||
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
|
}
|
||||||
|
return handled ;
|
||||||
|
}
|
||||||
void wxApp::MacHandleActivateEvent( WXEVENTREF evr )
|
void wxApp::MacHandleActivateEvent( WXEVENTREF evr )
|
||||||
{
|
{
|
||||||
EventRecord* ev = (EventRecord*) evr ;
|
EventRecord* ev = (EventRecord*) evr ;
|
||||||
|
@@ -234,6 +234,8 @@ void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
|
|||||||
|
|
||||||
EventHandlerUPP wxMacWindowEventHandlerUPP = NULL ;
|
EventHandlerUPP wxMacWindowEventHandlerUPP = NULL ;
|
||||||
|
|
||||||
|
extern long wxMacTranslateKey(unsigned char key, unsigned char code) ;
|
||||||
|
|
||||||
pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||||
{
|
{
|
||||||
OSStatus result = eventNotHandledErr ;
|
OSStatus result = eventNotHandledErr ;
|
||||||
@@ -243,8 +245,18 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
|
|||||||
case kEventClassTextInput :
|
case kEventClassTextInput :
|
||||||
if ( wxMacConvertEventToRecord( event , &rec ) )
|
if ( wxMacConvertEventToRecord( event , &rec ) )
|
||||||
{
|
{
|
||||||
wxTheApp->MacHandleOneEvent( &rec ) ;
|
short keycode ;
|
||||||
result = noErr ;
|
short keychar ;
|
||||||
|
keychar = short(rec.message & charCodeMask);
|
||||||
|
keycode = short(rec.message & keyCodeMask) >> 8 ;
|
||||||
|
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
||||||
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
|
|
||||||
|
if ( wxTheApp->MacSendKeyDownEvent( focus , keyval , rec.modifiers , rec.when , rec.where.h , rec.where.v ) )
|
||||||
|
{
|
||||||
|
// was handled internally
|
||||||
|
result = noErr ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
default :
|
default :
|
||||||
|
@@ -234,6 +234,8 @@ void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
|
|||||||
|
|
||||||
EventHandlerUPP wxMacWindowEventHandlerUPP = NULL ;
|
EventHandlerUPP wxMacWindowEventHandlerUPP = NULL ;
|
||||||
|
|
||||||
|
extern long wxMacTranslateKey(unsigned char key, unsigned char code) ;
|
||||||
|
|
||||||
pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||||
{
|
{
|
||||||
OSStatus result = eventNotHandledErr ;
|
OSStatus result = eventNotHandledErr ;
|
||||||
@@ -243,8 +245,18 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
|
|||||||
case kEventClassTextInput :
|
case kEventClassTextInput :
|
||||||
if ( wxMacConvertEventToRecord( event , &rec ) )
|
if ( wxMacConvertEventToRecord( event , &rec ) )
|
||||||
{
|
{
|
||||||
wxTheApp->MacHandleOneEvent( &rec ) ;
|
short keycode ;
|
||||||
result = noErr ;
|
short keychar ;
|
||||||
|
keychar = short(rec.message & charCodeMask);
|
||||||
|
keycode = short(rec.message & keyCodeMask) >> 8 ;
|
||||||
|
long keyval = wxMacTranslateKey(keychar, keycode) ;
|
||||||
|
wxWindow* focus = wxWindow::FindFocus() ;
|
||||||
|
|
||||||
|
if ( wxTheApp->MacSendKeyDownEvent( focus , keyval , rec.modifiers , rec.when , rec.where.h , rec.where.v ) )
|
||||||
|
{
|
||||||
|
// was handled internally
|
||||||
|
result = noErr ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
default :
|
default :
|
||||||
|
Reference in New Issue
Block a user