// returns true if key was consumed
bool wxVListBoxComboPopup::HandleKey( int keycode, bool saturate, wxChar unicode )
{
+ const int itemCount = GetCount();
+
+ // keys do nothing in the empty control and returning immediately avoids
+ // using invalid indices below
+ if ( !itemCount )
+ return false;
+
int value = m_value;
- int itemCount = GetCount();
int comboStyle = m_combo->GetWindowStyle();
// this is the character equivalent of the code
- wxChar keychar=0;
- if ((keycode >= WXK_SPACE) && (keycode <=255) && (keycode != WXK_DELETE) && wxIsprint(keycode))
- {
- keychar = (wxChar)keycode;
- }
- else if (unicode>0)
+ wxChar keychar = 0;
+ if ( keycode < WXK_START )
{
- keychar = unicode;
+ if ( unicode > 0 )
+ {
+ if ( wxIsprint(unicode) )
+ keychar = unicode;
+ }
+ else if ( wxIsprint(keycode) )
+ {
+ keychar = (wxChar) keycode;
+ }
}
if ( keycode == WXK_DOWN || keycode == WXK_RIGHT )
value-=10;
StopPartialCompletion();
}
- else if ( comboStyle & wxCB_READONLY )
+ else if ( keychar && (comboStyle & wxCB_READONLY) )
{
// Try partial completion
}
m_strings.Insert(item,pos);
- m_clientDatas.Insert(NULL, pos);
+ if ( (int)m_clientDatas.size() >= pos )
+ m_clientDatas.Insert(NULL, pos);
m_widths.Insert(-1,pos);
m_widthsDirty = true;
EnsurePopupControl();
const unsigned int count = items.GetCount();
- for( unsigned int i = 0; i < count; ++i, ++pos )
+
+ if ( HasFlag(wxCB_SORT) )
{
- GetVListBoxComboPopup()->Insert(items[i], pos);
- AssignNewItemClientData(pos, clientData, i, type);
+ int n = pos;
+
+ for ( unsigned int i = 0; i < count; ++i )
+ {
+ int n = GetVListBoxComboPopup()->Append(items[i]);
+ AssignNewItemClientData(n, clientData, i, type);
+ }
+
+ return n;
}
+ else
+ {
+ for ( unsigned int i = 0; i < count; ++i, ++pos )
+ {
+ GetVListBoxComboPopup()->Insert(items[i], pos);
+ AssignNewItemClientData(pos, clientData, i, type);
+ }
- return pos - 1;
+ return pos - 1;
+ }
}
void wxOwnerDrawnComboBox::DoSetItemClientData(unsigned int n, void* clientData)