[wx-dev] What is the reason behind this code?

Vadim Zeitlin vadim at wxwindows.org
Tue Apr 3 04:37:32 PDT 2007


On Tue, 3 Apr 2007 00:28:09 -0700 (GMT-07:00) Igor Korot <ikorot at earthlink.net> wrote:

IK> grid.cpp, void wxGridCellChoiceEditor::BeginEdit(...)
IK> 
IK> .....
IK>     if (m_allowOthers)
IK>     {
IK>         Combo()->SetValue(m_startValue);
IK>     }
IK>     else
IK>     {
IK>         // find the right position, or default to the first if not found
IK>         int pos = Combo()->FindString(m_startValue);
IK> //        if (pos == wxNOT_FOUND)
IK> //            pos = 0;
IK>         Combo()->SetSelection(pos);
IK>     }

[NB: in the cvs sources these 2 lines are *not* commented out]

IK> Why do we default to the first value?
IK> There is a possible wxNOT_FOUND choice for the wxCombo/wxChoice control...
IK> Besides it will bring the cell editor in sync with the control behavior.

 I believe that the current behaviour is correct if m_allowOthers == false
as then it shouldn't be possible at all for m_startValue to be anything
else than one of the combobox elements. However with m_allowOthers == true
we indeed shouldn't force the selection to 0 but instead call
Combo()->SetValue(m_startValue) probably.

 Regards,
VZ





More information about the wx-dev mailing list