Change strategy for committing values from SIM_MODEL propGrid.

Note that the PCB editor's propGrid doesn't seem to need this workaround,
but I haven't yet figured out what's different between it and the sim model
propGrid.

Fixes https://gitlab.com/kicad/code/kicad/issues/13852
This commit is contained in:
Jeff Young 2023-02-24 14:19:01 +00:00
parent 200a06a677
commit c188318174
2 changed files with 16 additions and 19 deletions

View File

@ -295,11 +295,6 @@ bool DIALOG_SIM_MODEL<T_symbol, T_field>::TransferDataFromWindow()
{
m_pinAssignmentsGrid->CommitPendingChanges();
// This should have been done in wxPGTextCtrlEditor::OnTextCtrlEvent(), but something must
// be clearing it before we get here, resulting in CommitChangesFromEditor() doing nothing
m_paramGrid->GetGrid()->EditorsValueWasModified();
m_paramGrid->GetGrid()->CommitChangesFromEditor();
if( !DIALOG_SIM_MODEL_BASE::TransferDataFromWindow() )
return false;
@ -1241,11 +1236,6 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::onTypeChoice( wxCommandEvent& aEvent )
template <typename T_symbol, typename T_field>
void DIALOG_SIM_MODEL<T_symbol, T_field>::onPageChanging( wxBookCtrlEvent& event )
{
// This should have been done in wxPGTextCtrlEditor::OnTextCtrlEvent(), but something must
// be clearing it before we get here, resulting in CommitChangesFromEditor() doing nothing
m_paramGrid->GetGrid()->EditorsValueWasModified();
m_paramGrid->GetGrid()->CommitChangesFromEditor();
updateModelCodeTab( &curModel() );
}
@ -1295,10 +1285,7 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::onParamGridSetFocus( wxFocusEvent& aEv
// Tab key is pressed. This is inconvenient, so we fix that here.
wxPropertyGrid* grid = m_paramGrid->GetGrid();
grid->CommitChangesFromEditor();
wxPGProperty* selected = grid->GetSelection();
wxPGProperty* selected = grid->GetSelection();
if( !selected )
selected = grid->wxPropertyGridInterface::GetFirst();
@ -1315,8 +1302,6 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::onParamGridSelectionChange( wxProperty
{
wxPropertyGrid* grid = m_paramGrid->GetGrid();
grid->CommitChangesFromEditor();
// Jump over categories.
if( grid->GetSelection() && grid->GetSelection()->IsCategory() )
{
@ -1395,10 +1380,7 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::onUpdateUI( wxUpdateUIEvent& aEvent )
wxRect gridRect = grid->GetScreenRect();
if( ctrlRect.GetTop() < gridRect.GetTop() || ctrlRect.GetBottom() > gridRect.GetBottom() )
{
grid->CommitChangesFromEditor();
grid->ClearSelection();
}
}
#endif
}

View File

@ -134,6 +134,21 @@ bool SIM_STRING_PROPERTY::OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_prima
}
}
if( wxPropertyGrid* propGrid = dynamic_cast<wxPropertyGrid*>( wnd_primary->GetParent() ) )
{
// This doesn't seem like it should be required, as wxPGTextCtrlEditor::OnTextCtrlEvent()
// should be setting the value to modified. But it doesn't (or the modified flag is
// cleared at some point later), and even if it is set, the changes don't get committed.
// (We used to have code in DIALOG_SIM_MODEL to commit things on *some* actions, but it
// wasn't complete and this appears to have at least a better hit rate.)
propGrid->CallAfter(
[propGrid]()
{
propGrid->EditorsValueWasModified();
propGrid->CommitChangesFromEditor();
} );
}
return false;
}