Add DoShowCellEditControl() showing the editor unconditionally
It doesn't make sense to perform the checks in ShowCellEditControl() when it's called from EnableCellEditControl() and this makes the code unnecessarily fragile as m_cellEditCtrlEnabled needs to be set at just the right moment for it to work correctly. Call the new DoShowCellEditControl() instead and perform the checks only in the public function, for compatibility. Also note in a comment and the documentation that ShowCellEditControl() is not very useful anyhow and that EnableCellEditControl() should most often be used instead. No real changes (the commit is best viewed ignoring whitespace changes).
This commit is contained in:
@@ -1509,7 +1509,7 @@ public:
|
|||||||
|
|
||||||
bool IsCurrentCellReadOnly() const;
|
bool IsCurrentCellReadOnly() const;
|
||||||
|
|
||||||
void ShowCellEditControl();
|
void ShowCellEditControl(); // Use EnableCellEditControl() instead.
|
||||||
void HideCellEditControl();
|
void HideCellEditControl();
|
||||||
void SaveEditControlValue();
|
void SaveEditControlValue();
|
||||||
|
|
||||||
@@ -2908,6 +2908,9 @@ private:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show the cell editor for the current cell unconditionally.
|
||||||
|
void DoShowCellEditControl();
|
||||||
|
|
||||||
// Accept the changes in the edit control, i.e. save them to the table and
|
// Accept the changes in the edit control, i.e. save them to the table and
|
||||||
// dismiss the editor.
|
// dismiss the editor.
|
||||||
void DoAcceptCellEditControl();
|
void DoAcceptCellEditControl();
|
||||||
|
@@ -3827,8 +3827,9 @@ public:
|
|||||||
Displays the active in-place cell edit control for the current cell
|
Displays the active in-place cell edit control for the current cell
|
||||||
after it was hidden.
|
after it was hidden.
|
||||||
|
|
||||||
Note that this method does @em not start editing the cell, this is only
|
This method should only be called after calling HideCellEditControl(),
|
||||||
done by EnableCellEditControl().
|
to start editing the current grid cell use EnableCellEditControl()
|
||||||
|
instead.
|
||||||
*/
|
*/
|
||||||
void ShowCellEditControl();
|
void ShowCellEditControl();
|
||||||
|
|
||||||
|
@@ -7153,10 +7153,9 @@ void wxGrid::EnableCellEditControl( bool enable )
|
|||||||
if ( SendEvent(wxEVT_GRID_EDITOR_SHOWN) == -1 )
|
if ( SendEvent(wxEVT_GRID_EDITOR_SHOWN) == -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// do it before ShowCellEditControl()
|
m_cellEditCtrlEnabled = true;
|
||||||
m_cellEditCtrlEnabled = enable;
|
|
||||||
|
|
||||||
ShowCellEditControl();
|
DoShowCellEditControl();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -7206,7 +7205,12 @@ void wxGrid::ShowCellEditControl()
|
|||||||
m_cellEditCtrlEnabled = false;
|
m_cellEditCtrlEnabled = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
DoShowCellEditControl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGrid::DoShowCellEditControl()
|
||||||
{
|
{
|
||||||
wxRect rect = CellToRect( m_currentCellCoords );
|
wxRect rect = CellToRect( m_currentCellCoords );
|
||||||
int row = m_currentCellCoords.GetRow();
|
int row = m_currentCellCoords.GetRow();
|
||||||
@@ -7335,8 +7339,6 @@ void wxGrid::ShowCellEditControl()
|
|||||||
editor->BeginEdit(row, col, this);
|
editor->BeginEdit(row, col, this);
|
||||||
editor->SetCellAttr(NULL);
|
editor->SetCellAttr(NULL);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGrid::HideCellEditControl()
|
void wxGrid::HideCellEditControl()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user