- wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
- int tmp = (int) pos;
- if (m_windowStyle & wxTE_MULTILINE)
- gtk_text_set_point( GTK_TEXT(m_text), tmp );
- else
- gtk_entry_set_position( GTK_ENTRY(m_text), tmp );
+ int len;
+ wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
+ if (m_windowStyle & wxTE_MULTILINE) {
+ //gtk_text_set_point( GTK_TEXT(m_text), (int)pos );
+ /* HH: The call commented out above doesn't do anything. Don't know
+ * why. The code below isn't perfect either; it doesn't move the
+ * actual cursor, but subsequent calls to WriteText will insert
+ * text at the set position and move the displayed cursor behind it as
+ * well. I guess this is good enough for most uses. */
+ len = gtk_text_get_length( GTK_TEXT(m_text) );
+ if ( (pos < 0) || (pos > len) )
+ pos = len;
+ GTK_EDITABLE(m_text)->current_pos = (int)pos;
+ }
+ else
+ gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );