Show dropdown when editing is started

This commit is contained in:
Ocraftyone 2023-11-19 02:10:15 -05:00
parent 3f0083c5a7
commit 6e7dfc54e4
No known key found for this signature in database
GPG key ID: 85836ED21AD4D125
4 changed files with 16 additions and 15 deletions

View file

@ -54,7 +54,7 @@ private:
DECLARE_VARIANT_OBJECT(DataViewBitmapText)
// ----------------------------------------------------------------------------
// BitmapTextRenderer
// BitmapTextRenderer - an editable text box within a DataView item
// ----------------------------------------------------------------------------
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
class BitmapTextRenderer : public wxDataViewRenderer
@ -126,7 +126,7 @@ private:
// ----------------------------------------------------------------------------
// BitmapChoiceRenderer
// BitmapChoiceRenderer - Creates an editable ComboBox within a DataView item
// ----------------------------------------------------------------------------
class BitmapChoiceRenderer : public wxDataViewCustomRenderer

View file

@ -5485,6 +5485,10 @@ void ObjectList::ItemValueChanged(wxDataViewEvent &event)
// Here the last active column is forgotten, so when leaving the editing mode, the next mouse click will not enter the editing mode of the newly selected column.
void ObjectList::OnEditingStarted(wxDataViewEvent &event)
{
if (event.GetColumn() == colFilament) {
::ComboBox*c = static_cast<::ComboBox *>(event.GetDataViewColumn()->GetRenderer()->GetEditorCtrl());
c->ToggleDropDown();
}
#ifdef __WXMSW__
m_last_selected_column = -1;
#else

View file

@ -230,9 +230,7 @@ void ComboBox::DoSetItemClientData(unsigned int n, void *data)
datas[n] = data;
}
void ComboBox::mouseDown(wxMouseEvent &event)
{
SetFocus();
void ComboBox::ToggleDropDown(){
if (drop_down) {
drop.Hide();
} else if (drop.HasDismissLongTime()) {
@ -244,6 +242,12 @@ void ComboBox::mouseDown(wxMouseEvent &event)
}
}
void ComboBox::mouseDown(wxMouseEvent &event)
{
SetFocus();
ToggleDropDown();
}
void ComboBox::mouseWheelMoved(wxMouseEvent &event)
{
event.Skip();
@ -261,15 +265,7 @@ void ComboBox::keyDown(wxKeyEvent& event)
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_SPACE:
if (drop_down) {
drop.DismissAndNotify();
} else if (drop.HasDismissLongTime()) {
drop.autoPosition();
drop_down = true;
drop.Popup();
wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
GetEventHandler()->ProcessEvent(e);
}
ToggleDropDown();
break;
case WXK_UP:
case WXK_DOWN:

View file

@ -32,7 +32,6 @@ public:
virtual bool SetFont(wxFont const & font) override;
public:
int Append(const wxString &item, const wxBitmapBundle &bitmap = wxNullBitmap);
int Append(const wxString &item, const wxBitmapBundle &bitmap, void *clientData);
@ -62,6 +61,8 @@ public:
wxBitmap GetItemBitmap(unsigned int n);
void SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap);
void ToggleDropDown();
protected:
virtual int DoInsertItems(const wxArrayStringsAdapter &items,
unsigned int pos,