Caution: This version of this document is no longer maintained. For the latest documentation, see


Set the selected range for a PtText widget


int PtTextSetSelection( PtWidget_t *widget, 
                        int *start, 
                        int *end );


This function sets the selected range for a PtText. When the function completes successfully, start and end contain the range actually selected (start < end). These values may differ from the original values you specified if:

Both start and end are 0-based. So, for example, if start is 0, it indicates the first character in the widget's text buffer.

This function causes a nondestructive deselect of the currently selected range, if there is one.

Here's how a selected range behaves:


The number of characters successfully selected (which may be 0 if *start equals *end or if *start and *end are both greater than the number of characters in the widget), or -1 if the specified widget isn't a PtText widget.



Interrupt handler No
Signal handler No
Thread No

See also:

PtText, PtTextGetSelection()