WxComboBox
From WxWiki
A combobox is a listbox combined with an edit control at the top. Only one item can be selected. There are two other slightly different types of listboxes:
wxChoice: A listbox without an edit control. You can only see the selected item. wxChoice Class Reference
wxListBox: A listbox with an edit control. You can select more than one item and multiple items are visible. wxListBox Class Reference
[edit] Tab Traversal with wxTE_PROCESS_ENTER
Note: If you want to use EVT_TEXT_ENTER(id,func) to receive wxEVT_COMMAND_TEXT_ENTER events, you have to add the wxTE_PROCESS_ENTER window style flag.
If you create a wxComboBox with the flag wxTE_PROCESS_ENTER, the tab key won't jump to the next control anymore. To get the default tab-traversal behaviour back, you have to catch the KEY_DOWN events of the combo box and call Navigate() on the frame.
wxComboBox* box = new wxComboBox(parent, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize,
0, NULL, wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
box->GetEventHandler()->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MainFrame::comboTabAction));
void MainFrame::comboTabAction(wxKeyEvent& event)
{
if (event.GetKeyCode() == WXK_TAB)
Navigate(wxNavigationKeyEvent::IsForward);
else
event.Skip();
}
Perl Code Example:
### p__:
sub CboBoxOnKeyDown {
my( $this, $event ) = @_;
### p__: recognize tabkey in combobox
if(000){}
elsif( $event->GetKeyCode() == ord( "\t" ) ) {
my $oElt = ($this->GetParent()->GetChildren())[0];
$oElt->SetFocus();
}
else {
$event->Skip();
}
};
NOTE: The perl example sets focus on a specific control; I could not figure out how to get the Navigate method to work in perl. If you know how, please specify.
Python Code Example (found in wx\lib\calendar.py)
def OnKeyDown(self, event):
key_code = event.GetKeyCode()
if key_code == wx.WXK_TAB:
forward = not event.ShiftDown()
ne = wx.NavigationKeyEvent()
ne.SetDirection(forward)
ne.SetCurrentFocus(self)
ne.SetEventObject(self)
self.GetParent().GetEventHandler().ProcessEvent(ne)
event.Skip()
