Lingo Dictionary > O-R > pointToWord() |  |

pointToWord()

Syntax

    sprite(whichSpriteNumber).pointToWord(pointToTranslate)
    pointToWord(sprite spriteNumber, pointToTranslate)

Description

Function; returns an integer representing the number of a word located within the text or field sprite `spriteNumber` at screen coordinate `pointToTranslate`, or returns -1 if the point is not within the text. Words are separated by spaces`` in a block of text.

This function can be used to determine the word under the cursor.

Example

This Lingo displays the number of the word being clicked, as well as the text of the word, in the Message window:

    property spriteNum

    on mouseDown me
    	pointClicked = the mouseLoc
    	currentMember = sprite(spriteNum).member
    	wordNum = sprite(spriteNum).pointToWord(pointClicked)
    	wordText = currentMember.word[wordNum]
    	put "Clicked word" && wordNum & ", the text" && wordText
    end

See also

`itemDelimiter`, `mouseLoc`, `pointToChar()`, `pointToItem()`, `pointToLine()`, `pointToParagraph()`