Type Function Object TextField Library native.* Return value none Revision Release 2024.3703 Keywords setTextColor, color, text
Sets the color of the text in a native text input field.
object:setTextColor( r, g, b ) object:setTextColor( r, g, b, a )
Number. A value between 0
and 1
for red, green, and blue channels.
Number. A value between 0
and 1
for the alpha channel. Default is 1
. This can not be changed on Windows.
If you are passing a table of color values to this function, the table must be unpacked so that the color values are dictated properly:
local field1 = native.newTextField( 50, 100, 100, 35 ) local colorTable = { 1, 0, 0, 0.5 } field1:setTextColor( unpack(colorTable) )
local field1 = native.newTextField( 50, 100, 100, 35 ) field1.align = "center" field1:setTextColor( 1, 0.5, 0 ) field1.text = "Hello World!"