Don't delete text when cancelling changes.
Also changes margins of compile button so it correctly lines up at the top of the error window. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16002
This commit is contained in:
parent
b4602616c2
commit
50ff5e616f
|
@ -356,7 +356,7 @@ bool DIALOG_SHIM::Enable( bool enable )
|
|||
// Recursive descent doing a SelectAll() in wxTextCtrls.
|
||||
// MacOS User Interface Guidelines state that when tabbing to a text control all its
|
||||
// text should be selected. Since wxWidgets fails to implement this, we do it here.
|
||||
void DIALOG_SHIM::selectAllInTextCtrls( wxWindowList& children )
|
||||
void DIALOG_SHIM::SelectAllInTextCtrls( wxWindowList& children )
|
||||
{
|
||||
for( wxWindow* child : children )
|
||||
{
|
||||
|
@ -392,6 +392,10 @@ void DIALOG_SHIM::selectAllInTextCtrls( wxWindowList& children )
|
|||
{
|
||||
// Respect an existing selection
|
||||
}
|
||||
else if( scintilla->GetMarginType( 0 ) == wxSTC_MARGIN_NUMBER )
|
||||
{
|
||||
// Don't select-all in Custom Rules, etc.
|
||||
}
|
||||
else if( scintilla->IsEditable() )
|
||||
{
|
||||
scintilla->SelectAll();
|
||||
|
@ -416,7 +420,7 @@ void DIALOG_SHIM::selectAllInTextCtrls( wxWindowList& children )
|
|||
#endif
|
||||
else
|
||||
{
|
||||
selectAllInTextCtrls( child->GetChildren() );
|
||||
SelectAllInTextCtrls( child->GetChildren() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -428,7 +432,7 @@ void DIALOG_SHIM::OnPaint( wxPaintEvent &event )
|
|||
{
|
||||
KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( this );
|
||||
|
||||
selectAllInTextCtrls( GetChildren() );
|
||||
SelectAllInTextCtrls( GetChildren() );
|
||||
|
||||
if( m_initialFocusTarget )
|
||||
KIPLATFORM::UI::ForceFocus( m_initialFocusTarget );
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <widgets/wx_treebook.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <dialog_shim.h>
|
||||
|
||||
|
||||
class LAZY_PAGE : public wxPanel
|
||||
|
@ -48,6 +49,9 @@ public:
|
|||
m_mainSizer->Layout();
|
||||
|
||||
m_contents->TransferDataToWindow();
|
||||
|
||||
if( DIALOG_SHIM* dlg = dynamic_cast<DIALOG_SHIM*>( wxGetTopLevelParent( this ) ) )
|
||||
dlg->SelectAllInTextCtrls( GetChildren() );
|
||||
}
|
||||
|
||||
return m_contents;
|
||||
|
|
|
@ -123,6 +123,8 @@ public:
|
|||
return m_units;
|
||||
}
|
||||
|
||||
void SelectAllInTextCtrls( wxWindowList& children );
|
||||
|
||||
void SetupStandardButtons( std::map<int, wxString> aLabels = {} );
|
||||
|
||||
static bool IsCtrl( int aChar, const wxKeyEvent& e )
|
||||
|
@ -181,8 +183,6 @@ protected:
|
|||
virtual void OnCharHook( wxKeyEvent& aEvt );
|
||||
|
||||
private:
|
||||
void selectAllInTextCtrls( wxWindowList& children );
|
||||
|
||||
/**
|
||||
* Properly handle the wxCloseEvent when in the quasimodal mode when not calling
|
||||
* EndQuasiModal which is possible with any dialog derived from #DIALOG_SHIM.
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <drc/drc_rule_parser.h>
|
||||
#include <tools/drc_tool.h>
|
||||
#include <pgm_base.h>
|
||||
#include "wildcards_and_files_ext.h"
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
PANEL_SETUP_RULES::PANEL_SETUP_RULES( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ) :
|
||||
PANEL_SETUP_RULES_BASE( aParentWindow ),
|
||||
|
@ -97,8 +97,13 @@ void PANEL_SETUP_RULES::onCharHook( wxKeyEvent& aEvent )
|
|||
{
|
||||
if( m_originalText != m_textEditor->GetText() )
|
||||
{
|
||||
if( !IsOK( this, _( "Cancel Changes?" ) ) )
|
||||
return;
|
||||
if( IsOK( this, _( "Cancel Changes?" ) ) )
|
||||
{
|
||||
m_textEditor->SetText( m_originalText );
|
||||
m_textEditor->SelectAll();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,15 +67,15 @@ PANEL_SETUP_RULES_BASE::PANEL_SETUP_RULES_BASE( wxWindow* parent, wxWindowID id,
|
|||
m_textEditor->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY );
|
||||
m_textEditor->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
m_textEditor->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
|
||||
m_topMargin->Add( m_textEditor, 3, wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP, 5 );
|
||||
m_topMargin->Add( m_textEditor, 3, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
wxBoxSizer* bSizer5;
|
||||
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_compileButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|0 );
|
||||
m_compileButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 28,28 ), wxBU_AUTODRAW|0 );
|
||||
m_compileButton->SetToolTip( _("Check rule syntax") );
|
||||
|
||||
bSizer5->Add( m_compileButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
|
||||
bSizer5->Add( m_compileButton, 0, wxTOP|wxBOTTOM, 5 );
|
||||
|
||||
m_errorsReport = new WX_HTML_REPORT_BOX( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
|
||||
m_errorsReport->SetMinSize( wxSize( 400,60 ) );
|
||||
|
|
|
@ -214,7 +214,7 @@
|
|||
<property name="permission">protected</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP</property>
|
||||
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT</property>
|
||||
<property name="proportion">3</property>
|
||||
<object class="wxStyledTextCtrl" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -290,8 +290,8 @@
|
|||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">3</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxTOP|wxBOTTOM</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBitmapButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -348,7 +348,7 @@
|
|||
<property name="pressed"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size">40,40</property>
|
||||
<property name="size">28,28</property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
|
|
Loading…
Reference in New Issue