Edit One Field improvements.
1) Accept <enter> as OK if the multiline textbox isn't shown. 2) Focus and select all in first control if multiline textbox isn't shown. 3) Make title be title caps ("Edit Sheet name Field" looked dorky). Fixes https://gitlab.com/kicad/code/kicad/issues/7940
This commit is contained in:
parent
b4e2db5913
commit
f0e6f812ff
|
@ -212,6 +212,25 @@ wxString UnescapeString( const wxString& aSource )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString TitleCaps( const wxString& aString )
|
||||||
|
{
|
||||||
|
wxArrayString words;
|
||||||
|
wxString result;
|
||||||
|
|
||||||
|
wxStringSplit( aString, words, ' ' );
|
||||||
|
|
||||||
|
for( const wxString& word : words )
|
||||||
|
{
|
||||||
|
if( !result.IsEmpty() )
|
||||||
|
result += wxT( " " );
|
||||||
|
|
||||||
|
result += word.Capitalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int ReadDelimitedText( wxString* aDest, const char* aSource )
|
int ReadDelimitedText( wxString* aDest, const char* aSource )
|
||||||
{
|
{
|
||||||
std::string utf8; // utf8 but without escapes and quotes.
|
std::string utf8; // utf8 but without escapes and quotes.
|
||||||
|
|
|
@ -93,7 +93,10 @@ void DIALOG_EDIT_ONE_FIELD::init()
|
||||||
bool use_validator = m_fieldId == REFERENCE_FIELD
|
bool use_validator = m_fieldId == REFERENCE_FIELD
|
||||||
|| m_fieldId == VALUE_FIELD
|
|| m_fieldId == VALUE_FIELD
|
||||||
|| m_fieldId == FOOTPRINT_FIELD
|
|| m_fieldId == FOOTPRINT_FIELD
|
||||||
|| m_fieldId == DATASHEET_FIELD;
|
|| m_fieldId == DATASHEET_FIELD
|
||||||
|
|| m_fieldId == SHEETNAME_V
|
||||||
|
|| m_fieldId == SHEETFILENAME_V;
|
||||||
|
|
||||||
if( use_validator )
|
if( use_validator )
|
||||||
{
|
{
|
||||||
m_StyledTextCtrl->Show( false );
|
m_StyledTextCtrl->Show( false );
|
||||||
|
|
|
@ -166,3 +166,12 @@ bool DIALOG_LIB_EDIT_TEXT::TransferDataFromWindow()
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DIALOG_LIB_EDIT_TEXT::OnTextEnter( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
if( IsQuasiModal() )
|
||||||
|
EndQuasiModal( wxID_OK );
|
||||||
|
else
|
||||||
|
EndModal( wxID_OK );
|
||||||
|
}
|
|
@ -47,6 +47,8 @@ public:
|
||||||
DIALOG_LIB_EDIT_TEXT( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT* aText );
|
DIALOG_LIB_EDIT_TEXT( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT* aText );
|
||||||
~DIALOG_LIB_EDIT_TEXT() override {};
|
~DIALOG_LIB_EDIT_TEXT() override {};
|
||||||
|
|
||||||
|
void OnTextEnter( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool TransferDataToWindow() override;
|
bool TransferDataToWindow() override;
|
||||||
bool TransferDataFromWindow() override;
|
bool TransferDataFromWindow() override;
|
||||||
|
|
|
@ -29,7 +29,7 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
|
||||||
m_textLabel->Wrap( -1 );
|
m_textLabel->Wrap( -1 );
|
||||||
bTextValueBoxSizer->Add( m_textLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
bTextValueBoxSizer->Add( m_textLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
m_TextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
m_TextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
|
||||||
bTextValueBoxSizer->Add( m_TextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
bTextValueBoxSizer->Add( m_TextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||||
|
|
||||||
m_StyledTextCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString );
|
m_StyledTextCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString );
|
||||||
|
@ -220,6 +220,7 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
|
||||||
// Connect Events
|
// Connect Events
|
||||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCloseDialog ) );
|
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCloseDialog ) );
|
||||||
m_TextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this );
|
m_TextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this );
|
||||||
|
m_TextCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextEnter ), NULL, this );
|
||||||
m_StyledTextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this );
|
m_StyledTextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this );
|
||||||
m_TextValueSelectButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextValueSelectButtonClick ), NULL, this );
|
m_TextValueSelectButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextValueSelectButtonClick ), NULL, this );
|
||||||
}
|
}
|
||||||
|
@ -229,6 +230,7 @@ DIALOG_LIB_EDIT_TEXT_BASE::~DIALOG_LIB_EDIT_TEXT_BASE()
|
||||||
// Disconnect Events
|
// Disconnect Events
|
||||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCloseDialog ) );
|
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCloseDialog ) );
|
||||||
m_TextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this );
|
m_TextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this );
|
||||||
|
m_TextCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextEnter ), NULL, this );
|
||||||
m_StyledTextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this );
|
m_StyledTextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this );
|
||||||
m_TextValueSelectButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextValueSelectButtonClick ), NULL, this );
|
m_TextValueSelectButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextValueSelectButtonClick ), NULL, this );
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@
|
||||||
<property name="resize">Resizable</property>
|
<property name="resize">Resizable</property>
|
||||||
<property name="show">1</property>
|
<property name="show">1</property>
|
||||||
<property name="size"></property>
|
<property name="size"></property>
|
||||||
<property name="style"></property>
|
<property name="style">wxTE_PROCESS_ENTER</property>
|
||||||
<property name="subclass">; ; forward_declare</property>
|
<property name="subclass">; ; forward_declare</property>
|
||||||
<property name="toolbar_pane">0</property>
|
<property name="toolbar_pane">0</property>
|
||||||
<property name="tooltip"></property>
|
<property name="tooltip"></property>
|
||||||
|
@ -210,6 +210,7 @@
|
||||||
<property name="window_name"></property>
|
<property name="window_name"></property>
|
||||||
<property name="window_style"></property>
|
<property name="window_style"></property>
|
||||||
<event name="OnSetFocus">OnSetFocusText</event>
|
<event name="OnSetFocus">OnSetFocusText</event>
|
||||||
|
<event name="OnTextEnter">OnTextEnter</event>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
|
|
|
@ -73,6 +73,7 @@ class DIALOG_LIB_EDIT_TEXT_BASE : public DIALOG_SHIM
|
||||||
// Virtual event handlers, overide them in your derived class
|
// Virtual event handlers, overide them in your derived class
|
||||||
virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); }
|
virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); }
|
||||||
virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); }
|
virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnTextEnter( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnTextValueSelectButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnTextValueSelectButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1177,7 +1177,7 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField )
|
||||||
if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
|
if( aField->GetEditFlags() == 0 ) // i.e. not edited, or moved
|
||||||
saveCopyInUndoList( aField, UNDO_REDO::CHANGED );
|
saveCopyInUndoList( aField, UNDO_REDO::CHANGED );
|
||||||
|
|
||||||
wxString title = wxString::Format( _( "Edit %s Field" ), aField->GetName() );
|
wxString title = wxString::Format( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
|
||||||
|
|
||||||
DIALOG_SCH_EDIT_ONE_FIELD dlg( m_frame, title, aField );
|
DIALOG_SCH_EDIT_ONE_FIELD dlg( m_frame, title, aField );
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tool/tool_manager.h>
|
|
||||||
#include <tool/picker_tool.h>
|
#include <tool/picker_tool.h>
|
||||||
#include <tools/ee_selection_tool.h>
|
#include <tools/ee_selection_tool.h>
|
||||||
#include <tools/symbol_editor_pin_tool.h>
|
#include <tools/symbol_editor_pin_tool.h>
|
||||||
|
@ -30,7 +29,7 @@
|
||||||
#include <tools/symbol_editor_move_tool.h>
|
#include <tools/symbol_editor_move_tool.h>
|
||||||
#include <ee_actions.h>
|
#include <ee_actions.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <confirm.h>
|
#include <kicad_string.h>
|
||||||
#include <symbol_edit_frame.h>
|
#include <symbol_edit_frame.h>
|
||||||
#include <dialogs/dialog_lib_edit_draw_item.h>
|
#include <dialogs/dialog_lib_edit_draw_item.h>
|
||||||
#include <dialogs/dialog_lib_edit_text.h>
|
#include <dialogs/dialog_lib_edit_text.h>
|
||||||
|
@ -43,7 +42,6 @@
|
||||||
#include "symbol_editor_edit_tool.h"
|
#include "symbol_editor_edit_tool.h"
|
||||||
#include <math/util.h> // for KiROUND
|
#include <math/util.h> // for KiROUND
|
||||||
|
|
||||||
|
|
||||||
SYMBOL_EDITOR_EDIT_TOOL::SYMBOL_EDITOR_EDIT_TOOL() :
|
SYMBOL_EDITOR_EDIT_TOOL::SYMBOL_EDITOR_EDIT_TOOL() :
|
||||||
EE_TOOL_BASE( "eeschema.SymbolEditTool" ),
|
EE_TOOL_BASE( "eeschema.SymbolEditTool" ),
|
||||||
m_pickerItem( nullptr )
|
m_pickerItem( nullptr )
|
||||||
|
@ -521,7 +519,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField )
|
||||||
if( aField->GetId() == VALUE_FIELD )
|
if( aField->GetId() == VALUE_FIELD )
|
||||||
caption = _( "Edit Symbol Name" );
|
caption = _( "Edit Symbol Name" );
|
||||||
else
|
else
|
||||||
caption.Printf( _( "Edit %s Field" ), aField->GetName() );
|
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
|
||||||
|
|
||||||
DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
|
DIALOG_LIB_EDIT_ONE_FIELD dlg( m_frame, caption, aField );
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,11 @@ wxString UnescapeString( const wxString& aSource );
|
||||||
*/
|
*/
|
||||||
wxString PrettyPrintForMenu( const wxString& aString );
|
wxString PrettyPrintForMenu( const wxString& aString );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capitalize the first letter in each word.
|
||||||
|
*/
|
||||||
|
wxString TitleCaps( const wxString& aString );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy bytes from @a aSource delimited string segment to @a aDest buffer.
|
* Copy bytes from @a aSource delimited string segment to @a aDest buffer.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue