Browse Source

FONT_CHOICE: fix an issue specific to MSW

FONT_CHOICE use Clear() to delete the wxOwnerDrawnComboBox items on MSW.
however (wxWidgets bug?) it creates 2 issues: a wxWidgets alert and fires
OnTextCtrl events, creating annoying recursions because OnTextCtrl event
call Clear().
Looks like it did not happen on Linux.
So wxOwnerDrawnComboBox::Clear() is not used on MSW, and used on other platforms.
master
jean-pierre charras 2 weeks ago
parent
commit
fe2497f17d
  1. 23
      common/widgets/font_choice.cpp
  2. 3
      include/widgets/font_choice.h

23
common/widgets/font_choice.cpp

@ -205,6 +205,23 @@ FONT_CHOICE::~FONT_CHOICE()
}
void FONT_CHOICE::clearList()
{
// Do the same as wxOwnerDrawnComboBox::Clear().
// But, on MSW, Clear() has 2 issues:
// - it generate wxWidgets alerts
// - it generate a OnTextCtrl event, creating also recursions, not so easy to fix.
// We use wxOwnerDrawnComboBox::Delete that do not have these issues and can do the same job
#if defined( __WXMSW__ )
while( GetCount() )
Delete( GetCount() - 1 );
#else
Clear();
#endif
}
void FONT_CHOICE::RefreshFonts()
{
wxArrayString menuList = FONT_LIST_MANAGER::Get().GetFonts();
@ -223,7 +240,7 @@ void FONT_CHOICE::RefreshFonts()
m_fullFontList.Add( font );
Freeze();
Clear();
clearList();
if( m_systemFontCount > 1 )
Append( _( "Default Font" ) );
@ -732,7 +749,7 @@ void FONT_CHOICE::FilterFontList( const wxString& aFilter )
// Update the combo box with filtered list (even if empty)
Freeze();
Clear();
clearList();
if( haveItemsNow )
{
@ -789,7 +806,7 @@ void FONT_CHOICE::RestoreFullFontList()
wxString selection = GetValue();
Freeze();
Clear();
clearList();
Append( m_fullFontList );
m_isFiltered = false;

3
include/widgets/font_choice.h

@ -61,6 +61,9 @@ protected:
void OnKillFocus( wxFocusEvent& aEvent );
private:
// Clear the wxOwnerDrawnComboBox list.
// Same as wxOwnerDrawnComboBox::Clear(), but without issues related to Clear() (see code)
void clearList();
void DoAutoComplete( const wxString& aText );
void FilterFontList( const wxString& aFilter );
void RestoreFullFontList();

Loading…
Cancel
Save