Make wxEL_ALLOW_NEW imply wxEL_ALLOW_EDIT in wxEditableListBox

Without this change, using wxEL_ALLOW_NEW without wxEL_ALLOW_EDIT
resulted in an assertion failure, so fix it by turning wxEL_ALLOW_EDIT
too in this case: this makes sense because adding a new element is
"editing" too, and there doesn't seem to be any realistic scenario in
which new items can be added but the existing items can't be changed.

Closes #24099.

Closes #24100.
This commit is contained in:
Martin Corino 2023-11-30 20:41:42 +01:00 committed by Vadim Zeitlin
parent 11ed91af8f
commit ed02e03585
2 changed files with 6 additions and 2 deletions

View file

@ -19,7 +19,7 @@
@beginStyleTable @beginStyleTable
@style{wxEL_ALLOW_NEW} @style{wxEL_ALLOW_NEW}
Allows the user to enter new strings. Allows the user to enter new strings (implies wxEL_ALLOW_EDIT as well).
@style{wxEL_ALLOW_EDIT} @style{wxEL_ALLOW_EDIT}
Allows the user to edit existing strings. Allows the user to edit existing strings.
@style{wxEL_ALLOW_DELETE} @style{wxEL_ALLOW_DELETE}

View file

@ -113,6 +113,10 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id,
m_style = style; m_style = style;
// wxEL_ALLOW_NEW requires ability to edit labels so implicitly add wxEL_ALLOW_EDIT
if ( m_style & wxEL_ALLOW_NEW )
m_style |= wxEL_ALLOW_EDIT;
wxSizer *sizer = new wxBoxSizer(wxVERTICAL); wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxPanel *subp = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPanel *subp = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
@ -167,7 +171,7 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id,
sizer->Add(subp, wxSizerFlags().Expand()); sizer->Add(subp, wxSizerFlags().Expand());
long st = wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL | wxSUNKEN_BORDER; long st = wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL | wxSUNKEN_BORDER;
if ( style & wxEL_ALLOW_EDIT ) if ( m_style & wxEL_ALLOW_EDIT )
st |= wxLC_EDIT_LABELS; st |= wxLC_EDIT_LABELS;
m_listCtrl = new CleverListCtrl(this, wxID_ELB_LISTCTRL, m_listCtrl = new CleverListCtrl(this, wxID_ELB_LISTCTRL,
wxDefaultPosition, wxDefaultSize, st); wxDefaultPosition, wxDefaultSize, st);