Enable tab navigation and shift-return-for-OK in multiline text controls for text objects.
Fixes: lp:1420916 * https://bugs.launchpad.net/kicad/+bug/1420916
This commit is contained in:
parent
b55eb0b5f1
commit
fb597f4298
|
@ -51,6 +51,7 @@ class DIALOG_LABEL_EDITOR : public DIALOG_LABEL_EDITOR_BASE
|
|||
{
|
||||
public:
|
||||
DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem );
|
||||
~DIALOG_LABEL_EDITOR();
|
||||
|
||||
void SetTitle( const wxString& aTitle ) override
|
||||
{
|
||||
|
@ -81,6 +82,7 @@ private:
|
|||
virtual void OnEnterKey( wxCommandEvent& aEvent ) override;
|
||||
virtual void OnOkClick( wxCommandEvent& aEvent ) override;
|
||||
virtual void OnCancelClick( wxCommandEvent& aEvent ) override;
|
||||
void OnCharHook( wxKeyEvent& aEvent );
|
||||
void TextPropertiesAccept( wxCommandEvent& aEvent );
|
||||
|
||||
SCH_EDIT_FRAME* m_Parent;
|
||||
|
@ -123,11 +125,25 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe
|
|||
|
||||
m_TextSize->SetValidator( textSizeValidator );
|
||||
|
||||
// wxTextCtrls fail to generate wxEVT_CHAR events when the wxTE_MULTILINE flag is set,
|
||||
// so we have to listen to wxEVT_CHAR_HOOK events instead.
|
||||
m_textLabelMultiLine->Connect( wxEVT_CHAR_HOOK,
|
||||
wxKeyEventHandler( DIALOG_LABEL_EDITOR::OnCharHook ),
|
||||
NULL, this );
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
FinishDialogSettings();
|
||||
}
|
||||
|
||||
|
||||
DIALOG_LABEL_EDITOR::~DIALOG_LABEL_EDITOR()
|
||||
{
|
||||
m_textLabelMultiLine->Disconnect( wxEVT_CHAR_HOOK,
|
||||
wxKeyEventHandler( DIALOG_LABEL_EDITOR::OnCharHook ),
|
||||
NULL, this );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_LABEL_EDITOR::InitDialog()
|
||||
{
|
||||
wxString msg;
|
||||
|
@ -248,7 +264,7 @@ void DIALOG_LABEL_EDITOR::InitDialog()
|
|||
|
||||
|
||||
/*!
|
||||
* wxTE_PROCESS_ENTER event handler for m_textLabel
|
||||
* wxEVT_COMMAND_ENTER event handler for m_textLabel
|
||||
*/
|
||||
|
||||
void DIALOG_LABEL_EDITOR::OnEnterKey( wxCommandEvent& aEvent )
|
||||
|
@ -257,6 +273,33 @@ void DIALOG_LABEL_EDITOR::OnEnterKey( wxCommandEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_CHAR_HOOK event handler for m_textLabel
|
||||
*/
|
||||
|
||||
void DIALOG_LABEL_EDITOR::OnCharHook( wxKeyEvent& aEvent )
|
||||
{
|
||||
if( aEvent.GetKeyCode() == WXK_TAB )
|
||||
{
|
||||
int flags = 0;
|
||||
if( !aEvent.ShiftDown() )
|
||||
flags |= wxNavigationKeyEvent::IsForward;
|
||||
if( aEvent.ControlDown() )
|
||||
flags |= wxNavigationKeyEvent::WinChange;
|
||||
NavigateIn( flags );
|
||||
}
|
||||
else if( aEvent.GetKeyCode() == WXK_RETURN && aEvent.ShiftDown() )
|
||||
{
|
||||
wxCommandEvent cmdEvent( wxEVT_COMMAND_ENTER );
|
||||
TextPropertiesAccept( cmdEvent );
|
||||
}
|
||||
else
|
||||
{
|
||||
aEvent.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
||||
*/
|
||||
|
|
|
@ -55,6 +55,7 @@ class DIALOG_PCB_TEXT_PROPERTIES : public DIALOG_PCB_TEXT_PROPERTIES_BASE
|
|||
{
|
||||
public:
|
||||
DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, TEXTE_PCB* passedTextPCB, wxDC* DC = nullptr );
|
||||
~DIALOG_PCB_TEXT_PROPERTIES();
|
||||
|
||||
private:
|
||||
PCB_EDIT_FRAME* m_Parent;
|
||||
|
@ -76,6 +77,8 @@ private:
|
|||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
FinishDialogSettings();
|
||||
}
|
||||
|
||||
void OnCharHook( wxKeyEvent& aEvent );
|
||||
};
|
||||
|
||||
|
||||
|
@ -102,6 +105,19 @@ DIALOG_PCB_TEXT_PROPERTIES::DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent,
|
|||
|
||||
m_StandardSizerOK->SetDefault();
|
||||
|
||||
// wxTextCtrls fail to generate wxEVT_CHAR events when the wxTE_MULTILINE flag is set,
|
||||
// so we have to listen to wxEVT_CHAR_HOOK events instead.
|
||||
m_TextContentCtrl->Connect( wxEVT_CHAR_HOOK,
|
||||
wxKeyEventHandler( DIALOG_PCB_TEXT_PROPERTIES::OnCharHook ),
|
||||
NULL, this );
|
||||
}
|
||||
|
||||
|
||||
DIALOG_PCB_TEXT_PROPERTIES::~DIALOG_PCB_TEXT_PROPERTIES()
|
||||
{
|
||||
m_TextContentCtrl->Disconnect( wxEVT_CHAR_HOOK,
|
||||
wxKeyEventHandler( DIALOG_PCB_TEXT_PROPERTIES::OnCharHook ),
|
||||
NULL, this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,6 +140,29 @@ void PCB_EDIT_FRAME::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_PCB_TEXT_PROPERTIES::OnCharHook( wxKeyEvent& aEvent )
|
||||
{
|
||||
if( aEvent.GetKeyCode() == WXK_TAB )
|
||||
{
|
||||
int flags = 0;
|
||||
if( !aEvent.ShiftDown() )
|
||||
flags |= wxNavigationKeyEvent::IsForward;
|
||||
if( aEvent.ControlDown() )
|
||||
flags |= wxNavigationKeyEvent::WinChange;
|
||||
NavigateIn( flags );
|
||||
}
|
||||
else if( aEvent.GetKeyCode() == WXK_RETURN && aEvent.ShiftDown() )
|
||||
{
|
||||
TransferDataFromWindow();
|
||||
EndModal( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
aEvent.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_PCB_TEXT_PROPERTIES::TransferDataToWindow()
|
||||
{
|
||||
// Put units symbols to text labels where appropriate
|
||||
|
|
Loading…
Reference in New Issue