Push shift/cmd+<enter> processing down into dialog shim.

This will make them more uniform rather than only supported when
something else is using <enter>.

Fixes: lp:1838353
* https://bugs.launchpad.net/kicad/+bug/1838353
This commit is contained in:
Jeff Young 2019-08-13 16:52:34 +01:00
parent 045f5f6a61
commit a33d67f6b4
4 changed files with 18 additions and 17 deletions

View File

@ -61,6 +61,7 @@ BEGIN_EVENT_TABLE( DIALOG_SHIM, wxDialog )
// Esc key closes cell editor, otherwise Esc key closes the dialog.
EVT_GRID_EDITOR_SHOWN( DIALOG_SHIM::OnGridEditorShown )
EVT_GRID_EDITOR_HIDDEN( DIALOG_SHIM::OnGridEditorHidden )
EVT_CHAR_HOOK( DIALOG_SHIM::OnCharHook )
END_EVENT_TABLE()
@ -485,6 +486,16 @@ void DIALOG_SHIM::OnButton( wxCommandEvent& aEvent )
}
void DIALOG_SHIM::OnCharHook( wxKeyEvent& aEvt )
{
// shift-return (Mac default) or Ctrl-Return (GTK) for OK
if( aEvt.GetKeyCode() == WXK_RETURN && ( aEvt.ShiftDown() || aEvt.ControlDown() ) )
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
else
aEvt.Skip();
}
void DIALOG_SHIM::OnGridEditorShown( wxGridEvent& event )
{
SetEscapeId( wxID_NONE );

View File

@ -340,13 +340,6 @@ void GRID_TRICKS::onKeyDown( wxKeyEvent& ev )
return;
}
// shift-return (Mac default) or Ctrl-Return (GTK) for OK
if( ev.GetKeyCode() == WXK_RETURN && ( ev.ShiftDown() || ev.ControlDown() ) )
{
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
return;
}
// ctrl-tab for exit grid
#ifdef __APPLE__
bool ctrl = ev.RawControlDown();

View File

@ -264,8 +264,10 @@ void DIALOG_LABEL_EDITOR::OnCharHook( wxKeyEvent& aEvt )
if( aEvt.ControlDown() )
{
int flags = 0;
if( !aEvt.ShiftDown() )
flags |= wxNavigationKeyEvent::IsForward;
NavigateIn( flags );
}
else
@ -273,25 +275,18 @@ void DIALOG_LABEL_EDITOR::OnCharHook( wxKeyEvent& aEvt )
m_valueMultiLine->Tab();
}
}
else if( aEvt.GetKeyCode() == WXK_RETURN && aEvt.ShiftDown() )
{
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
}
else if( m_valueMultiLine->IsShown() && isCtrl( 'Z', aEvt ) )
{
m_valueMultiLine->Undo();
}
#if defined( __WXMAC__ )
else if( isShiftCtrl( 'Z', aEvt ) )
{
m_valueMultiLine->Redo();
}
else if( m_valueMultiLine->IsShown() && isShiftCtrl( 'Z', aEvt ) )
#else
else if( isCtrl( 'Y', aEvt ) )
else if( m_valueMultiLine->IsShown() && isCtrl( 'Y', aEvt ) )
#endif
{
m_valueMultiLine->Redo();
}
#endif
else if( isCtrl( 'X', aEvt ) )
{
m_valueMultiLine->Cut();

View File

@ -98,6 +98,8 @@ class DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER
*/
void OnButton( wxCommandEvent& aEvent );
void OnCharHook( wxKeyEvent& aEvt );
public:
DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,