CharPosToLoc
charPosToLoc
| |
---|---|
Type: | Field method |
Version: | 5.0 |
Language: | Lingo, JavaScript |
Dependencies: | none |
Links/Related | |
Movie properties: the mouseChar the mouseItem the mouseLine the mouseWord Field methods: field.locToCharPos() field.locVToLinePos() Field and Text sprite methods: sprite.pointToChar() sprite.pointToItem() sprite.pointToLine() sprite.pointToParagraph() sprite.pointToWord() |
Syntax
vLoc = fieldMember.charPosToLoc(<integer character position>)
Returns the point at the bottom left of the character at the given position in the given field member. The point is relative to the top left of the field member, even if the field member is scrolled on the Stage.
For most fonts, there will be a space between the bottom of the characters in line n and the top of the characters in line n+1. The following lines allow you to determine how high this interline white space will be:
vField = member("Field") vCharPos = vField.charPosToLoc(0) vLineHeight = vField.lineHeight vInterLine = vLineHeight - vCharPos.locV
For field members with the #wordWrap property set to FALSE, the following handler will return the width of a given line of text. Note that the position of the invisible RETURN character at the end of the line is used:
on GetLineWidth(aFieldMember, aLineNumber) vExtract = aFieldMember.text.line[1..aLineNumber] vCharsInExtract = vExtract.char.count -- final RETURN excluded vLastChar = vCharsInExtract + 1 -- includes final RETURN vLoc = aFieldMember.charPosToLoc(vLastChar) vLineWidth = vLoc.locH return vLineWidth end GetLineWidth
If the integer character position that you specify is greater than the number of characters in the field, then the bottom right corner of the last character is returned. (If it helps, you can think of this as the bottom left of the next character to be added at the end of the field).
See also
the mouseChar, the mouseItem, the mouseLine, the mouseWord, field.locToCharPos(), field.locVToLinePos(), sprite.pointToChar(), sprite.pointToItem(), sprite.pointToLine(), sprite.pointToParagraph(), sprite.pointToWord()