Parent document is top of "Motif FAQ (Part 4 of 9)"
Previous document is "105) How can I highlight text in the Text widget?"
Next document is "107) Can I customize the pointer cursor or insert position indicator"

106) How can I select all of the text in a widget programmatically?

So that some initial text is displayed, but anything typed replaces it.

[Last modified: July 95]

Answer:  XmTextSetSelection(Text1, 0, XmTextGetLastPosition(Text1), event-
>xbutton.time);

where Text1 is the widget in question (obviously) and event is some event that
triggered this call.  You can use XtLastTimestampProcessed( display) instead
of xbutton.time if you don't happen to have an event pointer handy.

Jon A. Christopher (jac8792@tam2000.tamu.edu) writes:

I have had difficulty getting this to work as described (even though it agrees
with the documentation).  I believe that it may be because I usually change
the TextField to some value and then try to select it.  I haven't looked at
the internals of the TextField widget, but it must only select the text if the
text hasn't changed since the time specified.  Ususally the
"LastTimestampProcessed" will be be *before* you modify the text, and the
selection is therefore ignored.  I'd suggest using the CurrentTime variable.
This is an X variable which, if used will make sure that your text is always
selected.

Parent document is top of "Motif FAQ (Part 4 of 9)"
Previous document is "105) How can I highlight text in the Text widget?"
Next document is "107) Can I customize the pointer cursor or insert position indicator"