Factor out DoAcceptCellEditControl() into a separate function
This allows to fold the last DoSaveEditControlValue() call into this function, so that it's only called from DoAcceptCellEditControl() or from SaveEditControlValue() (which is public, and hence can't be changed, even if its behaviour doesn't make much sense). This commit means that m_cellEditCtrlEnabled is now reset to false when AcceptCellEditControlIfShown() is called, which was not the case before, but this seems to make sense, as we shouldn't be just hiding the editor while leaving it enabled, and, also, doesn't really seem to change anything as hiding the editor indirectly results in a call to DisableCellEditControl(), via wxGrid::OnHideEditor(), and so it was actually already reset before -- but now this happens slightly earlier and more explicitly.
This commit is contained in:
@@ -2908,8 +2908,11 @@ private:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accept the changes in the edit control, if it's currently shown, and
|
// Accept the changes in the edit control, i.e. save them to the table and
|
||||||
// dismiss it.
|
// dismiss the editor.
|
||||||
|
void DoAcceptCellEditControl();
|
||||||
|
|
||||||
|
// As above, but do nothing if the control is not currently shown.
|
||||||
void AcceptCellEditControlIfShown();
|
void AcceptCellEditControlIfShown();
|
||||||
|
|
||||||
// Unlike the public SaveEditControlValue(), this method doesn't check if
|
// Unlike the public SaveEditControlValue(), this method doesn't check if
|
||||||
|
@@ -7170,15 +7170,7 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
{
|
{
|
||||||
SendEvent(wxEVT_GRID_EDITOR_HIDDEN);
|
SendEvent(wxEVT_GRID_EDITOR_HIDDEN);
|
||||||
|
|
||||||
HideCellEditControl();
|
DoAcceptCellEditControl();
|
||||||
|
|
||||||
// do it after HideCellEditControl() but before invoking
|
|
||||||
// user-defined handlers invoked by DoSaveEditControlValue() to
|
|
||||||
// ensure that we don't enter infinite loop if any of them try to
|
|
||||||
// disable the edit control again.
|
|
||||||
m_cellEditCtrlEnabled = false;
|
|
||||||
|
|
||||||
DoSaveEditControlValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7415,11 +7407,24 @@ void wxGrid::AcceptCellEditControlIfShown()
|
|||||||
{
|
{
|
||||||
if ( IsCellEditControlShown() )
|
if ( IsCellEditControlShown() )
|
||||||
{
|
{
|
||||||
HideCellEditControl();
|
DoAcceptCellEditControl();
|
||||||
DoSaveEditControlValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGrid::DoAcceptCellEditControl()
|
||||||
|
{
|
||||||
|
HideCellEditControl();
|
||||||
|
|
||||||
|
// do it after HideCellEditControl() but before invoking
|
||||||
|
// user-defined handlers invoked by DoSaveEditControlValue() to
|
||||||
|
// ensure that we don't enter infinite loop if any of them try to
|
||||||
|
// disable the edit control again by calling DisableCellEditControl()
|
||||||
|
// from which we can be called
|
||||||
|
m_cellEditCtrlEnabled = false;
|
||||||
|
|
||||||
|
DoSaveEditControlValue();
|
||||||
|
}
|
||||||
|
|
||||||
void wxGrid::SaveEditControlValue()
|
void wxGrid::SaveEditControlValue()
|
||||||
{
|
{
|
||||||
if ( IsCellEditControlEnabled() )
|
if ( IsCellEditControlEnabled() )
|
||||||
|
Reference in New Issue
Block a user