SelectedChunk

Thomas McGrath III 3mcgrath at adelphia.net
Mon Mar 21 07:59:31 EST 2005


selectedChunk function

Platform support:
Introduced in version 1.0

Returns a chunk expression describing the location of the text 
selection or insertion point.

the selectedChunk
selectedChunk

the selectedChunk
put the selectedChunk into storedChunk

See also: clickChunk function, foundChunk function, mouseChunk 
function, select command, selectedField function, selectedLine 
function, selectedLoc function, selectedText function, Why is the 
selected text deselected?, Why is the selection lost when clicking a 
button?

Description
Use the selectedChunk function to determine which text is selected.

Value:
The selectedChunk function returns a chunk expression of the form
   char startChar to endChar of field fieldNumber

Comments:
The return value reports the selected text: the startChar is the first 
character of the selection, and the endChar is the last character.

If no text is selected but the text insertion point is in a field, the 
startChar is the character after the insertion point, and the endChar 
is the character before the insertion point. In this case, the endChar 
is one less than the startChar.

If there is no insertion point or text selection, the selectedChunk 
function returns empty.

To get actual text that is selected, use the selectedText function.
Try

on tabKey
	put the selectedChunk into foo
	answer foo
end tabKey

On Mar 20, 2005, at 11:38 PM, Mikey wrote:

> on tabKey
>    get the selectedChunk
>    answer it
> end tabKey
>
> the variable watcher reports that IT is empty.  In addition, changing
> the code to
>
> on tabKey
>    put the selectedText into foo
>    answer foo
> end tabKey

Thomas J. McGrath III
SCS
1000 Killarney Dr.
Pittsburgh, PA 15234
412-885-8541


More information about the use-livecode mailing list