From ed02e035850202fa277d426f0537f05bdfc8fbee Mon Sep 17 00:00:00 2001 From: Martin Corino Date: Thu, 30 Nov 2023 20:41:42 +0100 Subject: [PATCH] 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. --- interface/wx/editlbox.h | 2 +- src/generic/editlbox.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/interface/wx/editlbox.h b/interface/wx/editlbox.h index 80462b24dc..445e60012c 100644 --- a/interface/wx/editlbox.h +++ b/interface/wx/editlbox.h @@ -19,7 +19,7 @@ @beginStyleTable @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} Allows the user to edit existing strings. @style{wxEL_ALLOW_DELETE} diff --git a/src/generic/editlbox.cpp b/src/generic/editlbox.cpp index 5f040ef227..641e541641 100644 --- a/src/generic/editlbox.cpp +++ b/src/generic/editlbox.cpp @@ -113,6 +113,10 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, 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); 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()); 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; m_listCtrl = new CleverListCtrl(this, wxID_ELB_LISTCTRL, wxDefaultPosition, wxDefaultSize, st);