measureText |
Type | function |
Dictionary | LCS |
Library | LiveCode Script |
Syntax | measureText(<text>,<objectReference>,[<mode>])
|
Summary | Returns the width, size or bounds of the text drawn with the
effective font attribute of the given object.
|
Introduced | 6.5 |
OS | mac, windows, linux, ios, android |
Platforms | desktop, server, mobile |
Parameters | Name | Type | Description |
---|
text | | Any text string, or an expression that evaluates to
a string.
|
objectReference | | An expression that evaluates to an object reference.
|
mode | | "width": (default if not specified)
"size":
"bounds":
|
|
Example | local tText, tTextWidth
put "Hello world" into tText
put measureText(tText,field "myField") into tTextWidth
local tText, tTextSize
put "Hello world" into field "someField"
put field "someField" into tText
put measureText(tText,field "someField","size") into tTextSize
on textChanged
local tTextBounds
put measureText("foo",me,"bounds") into tTextBounds
put "The text in this field has these bounds: " & tTextBounds
end textChanged
|
Values | Name | Type | Description |
---|
return | |
- width (number): the width of the text
- size (int,int): the width and height of the text as a
comma-separated list; e.g. width,height
- bounds (rect): a rectangle identifying the bounds of the text in the
form
0,-ascent,width,descent where ascent and descent are relative to
a 0 baseline the text is drawn on.
|
|
Related | Property: formattedWidth, formattedHeight
Message: textChanged
Glossary: return, expression, evaluate
Control Structure: function
|
Description | Use the measureText function to find the dimensions of the given
text if drawn using the effective font attributes of the object
specified in the objectReference parameter.
|
Tags | ui,text processing |