- if (m_windowStyle & wxTE_MULTILINE)
- {
- gint len = gtk_text_get_length( GTK_TEXT(m_text) );
- gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
- }
- else
- {
- gtk_entry_append_text( GTK_ENTRY(m_text), text );
- }
+ gtk_signal_disconnect_by_func( GTK_OBJECT(m_text),
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ /* this moves the cursor pos to behind the inserted text */
+ gint len = GTK_EDITABLE(m_text)->current_pos;
+
+#if wxUSE_UNICODE
+ wxWX2MBbuf buf = text.mbc_str();
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len );
+#else
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
+#endif
+
+ /* bring editable's cursor uptodate. bug in GTK. */
+ GTK_EDITABLE(m_text)->current_pos = gtk_text_get_point( GTK_TEXT(m_text) );
+ }
+ else
+ {
+ /* this moves the cursor pos to behind the inserted text */
+ gint len = GTK_EDITABLE(m_text)->current_pos;
+#if wxUSE_UNICODE
+ wxWX2MBbuf buf = text.mbc_str();
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len );
+#else
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), text, text.Length(), &len );
+#endif
+
+ /* bring editable's cursor uptodate. bug in GTK. */
+ GTK_EDITABLE(m_text)->current_pos += text.Len();
+
+ /* bring entry's cursor uptodate. bug in GTK. */
+ gtk_entry_set_position( GTK_ENTRY(m_text), GTK_EDITABLE(m_text)->current_pos );
+ }
+
+ gtk_signal_connect( GTK_OBJECT(m_text), "changed",
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);