Blitz3D+ Command Reference

TextAreaSelLen ( textarea[,units] )

Parameters

textarea - text area gadget

units (optional) - what to measure:
1: characters (default)
2: lines

Description

Returns the length of the current selection in a text area.

Requires Extended language mode.

Measures what the user has highlighted. TextAreaCursor gives where the selection starts, TextAreaSelLen how far it runs - together they form the range for the range commands, which is the whole recipe for tool features that act on "the selected text":

sel$=TextAreaText(area,TextAreaCursor(area),TextAreaSelLen(area))

Character units count whole Unicode characters, and 0 means nothing is selected - just a caret. Line units count the lines the selection touches, and always report at least 1, because even a bare caret sits on some line. So test for an empty selection with character units.

Selections a program cares about usually belong to the moment - read them when a menu command or button fires, rather than caching them.

The tree and text area sample shows the text area family working together.

See also: TextAreaCursor, TextAreaText, SetTextAreaText, FormatTextAreaText.

Index