X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5f346ddc0a4233f78c22a4f7a0501d9779732789..8dd7fd4e5d0c7585a8fc8278b95362771b5fbdaf:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 3dc367da3e..7e5b5f5472 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -955,6 +955,22 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags ) return; } + if (value.IsEmpty()) + { + if ( !(flags & SetValue_SendEvent) ) + EnableTextChangedEvents(false); + + gtk_text_buffer_set_text( m_buffer, "", 0 ); + + if ( !(flags & SetValue_SendEvent) ) + EnableTextChangedEvents(true); + + return; + } + +#ifdef wxUSE_UNICODE + const wxCharBuffer buffer(value.utf8_str()); +#else wxFontEncoding enc = m_defaultStyle.HasFont() ? m_defaultStyle.GetFont().GetEncoding() : wxFONTENCODING_SYSTEM; @@ -969,6 +985,7 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags ) wxLogWarning(_("Failed to set text in the text control.")); return; } +#endif if ( !(flags & SetValue_SendEvent) ) { @@ -1007,6 +1024,9 @@ void wxTextCtrl::WriteText( const wxString &text ) return; } +#ifdef wxUSE_UNICODE + const wxCharBuffer buffer(text.utf8_str()); +#else // check if we have a specific style for the current position wxFontEncoding enc = wxFONTENCODING_SYSTEM; wxTextAttr style; @@ -1027,6 +1047,7 @@ void wxTextCtrl::WriteText( const wxString &text ) wxLogWarning(_("Failed to insert text in the control.")); return; } +#endif // First remove the selection if there is one // TODO: Is there an easier GTK specific way to do this?