X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6eff83b827f998748777bb3f76db789fe099d6c1..18c0369bcdafbd32b826e4c1aa5717f0c6ebcc33:/src/richtext/richtextstyles.cpp diff --git a/src/richtext/richtextstyles.cpp b/src/richtext/richtextstyles.cpp index 731634e492..00b24a319a 100644 --- a/src/richtext/richtextstyles.cpp +++ b/src/richtext/richtextstyles.cpp @@ -520,6 +520,8 @@ void wxRichTextStyleListBox::UpdateStyles() { if (GetStyleSheet()) { + int oldSel = GetSelection(); + SetSelection(wxNOT_FOUND); m_styleNames.Clear(); @@ -546,9 +548,15 @@ void wxRichTextStyleListBox::UpdateStyles() Refresh(); - if (GetItemCount() > 0) + int newSel = -1; + if (oldSel >= 0 && oldSel < (int) GetItemCount()) + newSel = oldSel; + else if (GetItemCount() > 0) + newSel = 0; + + if (newSel >= 0) { - SetSelection(0); + SetSelection(newSel); SendSelectedEvent(); } } @@ -940,6 +948,7 @@ void wxRichTextStyleListCtrl::OnChooseType(wxCommandEvent& event) return; wxRichTextStyleListBox::wxRichTextStyleType styleType = StyleIndexToType(event.GetSelection()); + m_styleListBox->SetSelection(-1); m_styleListBox->SetStyleType(styleType); } }