Add shortcuts for the combobox (select all, copy, cut, paste)
* It is the same as the code in the implementation of the wxTextCtrl, I guess this could be extracted in a common function, but I don't know where to put it.
This commit is contained in:
@@ -130,11 +130,17 @@ protected:
|
|||||||
|
|
||||||
virtual void EnableTextChangedEvents(bool enable) wxOVERRIDE;
|
virtual void EnableTextChangedEvents(bool enable) wxOVERRIDE;
|
||||||
|
|
||||||
|
// callbacks
|
||||||
|
void OnKeyDown(wxKeyEvent& event); // Process clipboard shortcuts
|
||||||
|
|
||||||
// the subcontrols
|
// the subcontrols
|
||||||
wxComboBoxText* m_text;
|
wxComboBoxText* m_text;
|
||||||
wxComboBoxChoice* m_choice;
|
wxComboBoxChoice* m_choice;
|
||||||
|
|
||||||
wxComboBoxDataArray m_datas;
|
wxComboBoxDataArray m_datas;
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_COMBOBOX_H_
|
#endif // _WX_COMBOBOX_H_
|
||||||
|
@@ -18,6 +18,12 @@
|
|||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef wxWindowWithItems<wxControl, wxComboBoxBase> RealwxComboBoxBase;
|
||||||
|
|
||||||
|
wxBEGIN_EVENT_TABLE(wxComboBox, RealwxComboBoxBase)
|
||||||
|
EVT_KEY_DOWN(wxComboBox::OnKeyDown)
|
||||||
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
// work in progress
|
// work in progress
|
||||||
|
|
||||||
wxComboBox::~wxComboBox()
|
wxComboBox::~wxComboBox()
|
||||||
@@ -234,4 +240,33 @@ void wxComboBox::Dismiss()
|
|||||||
GetComboPeer()->Dismiss();
|
GetComboPeer()->Dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxComboBox::OnKeyDown(wxKeyEvent& event)
|
||||||
|
{
|
||||||
|
if (event.GetModifiers() == wxMOD_CONTROL)
|
||||||
|
{
|
||||||
|
switch(event.GetKeyCode())
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
SelectAll();
|
||||||
|
return;
|
||||||
|
case 'C':
|
||||||
|
if (CanCopy())
|
||||||
|
Copy();
|
||||||
|
return;
|
||||||
|
case 'V':
|
||||||
|
if (CanPaste())
|
||||||
|
Paste();
|
||||||
|
return;
|
||||||
|
case 'X':
|
||||||
|
if (CanCut())
|
||||||
|
Cut();
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// no, we didn't process it
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // wxUSE_COMBOBOX && wxOSX_USE_COCOA
|
#endif // wxUSE_COMBOBOX && wxOSX_USE_COCOA
|
||||||
|
Reference in New Issue
Block a user