Only reserve hotkeys for focused textCtrls that are editabled.
Otherwise just send Ctrl-C to the disabled control, and everything else to the tool framework. Fixes https://gitlab.com/kicad/code/kicad/issues/4801
This commit is contained in:
parent
7f991ce855
commit
e9da02e2d5
|
@ -311,24 +311,24 @@ void GRID_TRICKS::doPopupSelection( wxCommandEvent& event )
|
||||||
|
|
||||||
void GRID_TRICKS::onKeyDown( wxKeyEvent& ev )
|
void GRID_TRICKS::onKeyDown( wxKeyEvent& ev )
|
||||||
{
|
{
|
||||||
if( isCtl( 'A', ev ) )
|
if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() == 'A' )
|
||||||
{
|
{
|
||||||
m_grid->SelectAll();
|
m_grid->SelectAll();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if( isCtl( 'C', ev ) )
|
else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() == 'C' )
|
||||||
{
|
{
|
||||||
getSelectedArea();
|
getSelectedArea();
|
||||||
cutcopy( false );
|
cutcopy( false );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if( isCtl( 'V', ev ) )
|
else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() == 'V' )
|
||||||
{
|
{
|
||||||
getSelectedArea();
|
getSelectedArea();
|
||||||
paste_clipboard();
|
paste_clipboard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if( isCtl( 'X', ev ) )
|
else if( ev.GetModifiers() == wxMOD_CONTROL && ev.GetKeyCode() == 'X' )
|
||||||
{
|
{
|
||||||
getSelectedArea();
|
getSelectedArea();
|
||||||
cutcopy( true );
|
cutcopy( true );
|
||||||
|
|
|
@ -63,20 +63,6 @@ SCINTILLA_TRICKS::SCINTILLA_TRICKS( wxStyledTextCtrl* aScintilla, const wxString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SCINTILLA_TRICKS::isCtrl( int aChar, const wxKeyEvent& e )
|
|
||||||
{
|
|
||||||
return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() &&
|
|
||||||
!e.ShiftDown() && !e.MetaDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool SCINTILLA_TRICKS::isShiftCtrl( int aChar, const wxKeyEvent& e )
|
|
||||||
{
|
|
||||||
return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() &&
|
|
||||||
e.ShiftDown() && !e.MetaDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent )
|
void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent )
|
||||||
{
|
{
|
||||||
if( aEvent.GetKeyCode() == WXK_TAB )
|
if( aEvent.GetKeyCode() == WXK_TAB )
|
||||||
|
@ -101,23 +87,24 @@ void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent )
|
||||||
m_te->Tab();
|
m_te->Tab();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( isCtrl( 'Z', aEvent ) )
|
else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'Z' )
|
||||||
{
|
{
|
||||||
m_te->Undo();
|
m_te->Undo();
|
||||||
}
|
}
|
||||||
else if( isShiftCtrl( 'Z', aEvent ) || isCtrl( 'Y', aEvent ) )
|
else if( ( aEvent.GetModifiers() == wxMOD_SHIFT+wxMOD_CONTROL && aEvent.GetKeyCode() == 'Z' )
|
||||||
|
|| ( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'Y' ) )
|
||||||
{
|
{
|
||||||
m_te->Redo();
|
m_te->Redo();
|
||||||
}
|
}
|
||||||
else if( isCtrl( 'X', aEvent ) )
|
else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'X' )
|
||||||
{
|
{
|
||||||
m_te->Cut();
|
m_te->Cut();
|
||||||
}
|
}
|
||||||
else if( isCtrl( 'C', aEvent ) )
|
else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'C' )
|
||||||
{
|
{
|
||||||
m_te->Copy();
|
m_te->Copy();
|
||||||
}
|
}
|
||||||
else if( isCtrl( 'V', aEvent ) )
|
else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'V' )
|
||||||
{
|
{
|
||||||
m_te->Paste();
|
m_te->Paste();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,31 +26,18 @@
|
||||||
#include <textentry_tricks.h>
|
#include <textentry_tricks.h>
|
||||||
#include <dialog_shim.h>
|
#include <dialog_shim.h>
|
||||||
|
|
||||||
bool TEXTENTRY_TRICKS::isCtrl( int aChar, const wxKeyEvent& e )
|
|
||||||
{
|
|
||||||
return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() &&
|
|
||||||
!e.ShiftDown() && !e.MetaDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool TEXTENTRY_TRICKS::isShiftCtrl( int aChar, const wxKeyEvent& e )
|
|
||||||
{
|
|
||||||
return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() &&
|
|
||||||
e.ShiftDown() && !e.MetaDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TEXTENTRY_TRICKS::OnCharHook( wxTextEntry* aTextEntry, wxKeyEvent& aEvent )
|
void TEXTENTRY_TRICKS::OnCharHook( wxTextEntry* aTextEntry, wxKeyEvent& aEvent )
|
||||||
{
|
{
|
||||||
if( isCtrl( 'X', aEvent ) )
|
if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'X' )
|
||||||
{
|
{
|
||||||
aTextEntry->Cut();
|
aTextEntry->Cut();
|
||||||
}
|
}
|
||||||
else if( isCtrl( 'C', aEvent ) )
|
else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'C' )
|
||||||
{
|
{
|
||||||
aTextEntry->Copy();
|
aTextEntry->Copy();
|
||||||
}
|
}
|
||||||
else if( isCtrl( 'V', aEvent ) )
|
else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() == 'V' )
|
||||||
{
|
{
|
||||||
aTextEntry->Paste();
|
aTextEntry->Paste();
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,11 +485,30 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
||||||
|
|
||||||
keyIsEscape = ( ke->GetKeyCode() == WXK_ESCAPE );
|
keyIsEscape = ( ke->GetKeyCode() == WXK_ESCAPE );
|
||||||
|
|
||||||
if( dynamic_cast<wxTextEntry*>( focus ) || dynamic_cast<wxStyledTextCtrl*>( focus ) )
|
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
|
||||||
|
wxStyledTextCtrl* styledText = dynamic_cast<wxStyledTextCtrl*>( focus );
|
||||||
|
|
||||||
|
if( textEntry || styledText )
|
||||||
{
|
{
|
||||||
|
bool enabled = true;
|
||||||
|
|
||||||
|
if( textEntry )
|
||||||
|
enabled = textEntry->IsEditable();
|
||||||
|
else if( styledText )
|
||||||
|
enabled = styledText->IsEditable();
|
||||||
|
|
||||||
// Never process key events for tools when a text entry has focus
|
// Never process key events for tools when a text entry has focus
|
||||||
aEvent.Skip();
|
if( enabled )
|
||||||
return;
|
{
|
||||||
|
aEvent.Skip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Even if not enabled, allow a copy out
|
||||||
|
else if( ke->GetModifiers() == wxMOD_CONTROL && ke->GetKeyCode() == 'C' )
|
||||||
|
{
|
||||||
|
aEvent.Skip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
evt = GetToolEvent( ke, &keyIsSpecial );
|
evt = GetToolEvent( ke, &keyIsSpecial );
|
||||||
|
|
|
@ -67,11 +67,6 @@ protected:
|
||||||
/// Puts the selected area into a sensible rectangle of m_sel_{row,col}_{start,count} above.
|
/// Puts the selected area into a sensible rectangle of m_sel_{row,col}_{start,count} above.
|
||||||
void getSelectedArea();
|
void getSelectedArea();
|
||||||
|
|
||||||
static bool isCtl( int aChar, const wxKeyEvent& e )
|
|
||||||
{
|
|
||||||
return e.GetKeyCode() == aChar && e.ControlDown() && !e.AltDown() && !e.ShiftDown() && !e.MetaDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onGridCellLeftClick( wxGridEvent& event );
|
void onGridCellLeftClick( wxGridEvent& event );
|
||||||
void onGridCellLeftDClick( wxGridEvent& event );
|
void onGridCellLeftDClick( wxGridEvent& event );
|
||||||
void onGridCellRightClick( wxGridEvent& event );
|
void onGridCellRightClick( wxGridEvent& event );
|
||||||
|
|
|
@ -41,9 +41,6 @@ public:
|
||||||
void DoAutocomplete( const wxString& aPartial, const wxArrayString& aTokens );
|
void DoAutocomplete( const wxString& aPartial, const wxArrayString& aTokens );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isCtrl( int aChar, const wxKeyEvent& e );
|
|
||||||
bool isShiftCtrl( int aChar, const wxKeyEvent& e );
|
|
||||||
|
|
||||||
void onCharHook( wxKeyEvent& aEvent );
|
void onCharHook( wxKeyEvent& aEvent );
|
||||||
void onScintillaUpdateUI( wxStyledTextEvent& aEvent );
|
void onScintillaUpdateUI( wxStyledTextEvent& aEvent );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue