UI.TextField

From GiderosMobile

Available since: Gideros 2023.1
Class: UI

Description

Creates TextField widgets. The widget can be a TextField, a ButtonTextFieldCombo, a ButtonTextField or a PasswordField.

UI.TextField.new(text,layout,minwidth,minheight,pass,textType)
UI.ButtonTextFieldCombo.new(text,layout,minwidth,minheight,pass,textType)
UI.ButtonTextField.new(text,layout,minwidth,minheight,pass,textType)
UI.PasswordField.new(text,layout,minwidth,minheight,pass,textType)

Parameters

text: (string) the TextField widget text
layout: (string) the TextField widget layout
minwidth: (number) the TextField widget minimum width
minheight: (number) the TextField widget minimum height
pass: (string) the TextField widget hiding symbol
textType: (number) the TextField widget text type, see Application Constants

Examples

TextField position

UI.Style:setDefault(UI.Theme.PointCore_Base)
application:setBackgroundColor(0x000000)
--disable keyboards
UI.Keyboard.NATIVE=false
UI.Keyboard.VIRTUAL=false

local minX, minY, maxX, maxY = application:getLogicalBounds()
local screen=UI.Screen.new()
local cf = UI.TextField.new("", { readonly=true })
cf:setText("Some text")
cf:setLayoutConstraints({ fillx=0.5, anchorx=0.1, anchory=1, }) -- TextField x, y position
screen:ui(cf)

TextField

local gui = UI.TextField.new("hello Gideros UI", nil, 64, 64, nil, Application.TEXTINPUT_CLASS_TEXT)
gui:setDimensions(256, 96)
gui:setColor(0x5c5c5c)
gui:setPosition(50, 50)

gui:setTipText("some tip text")

local screen=UI.Screen.new() -- needed to add the TextField
screen:ui(gui)

Selectable TextField

UI.Style:setDefault(UI.Theme.PointCore_Pink)

local tf=UI.TextField.new("",{ flags=FontBase.TLF_TOP|FontBase.TLF_REF_TOP, multiline=true})
tf:setDimensions(200,500)
tf:setPosition(50,50)
tf:setText(
"You can select a \e[color=#F00]part\e[color] of this text.\nIt should even be possible\nwith multiline texts.\n\n"..
"Right mouse button to copy text."
)
tf:setFlags({ readonly=true, selectable=true })

local screen=UI.Screen.new()
screen:ui(tf)

ButtonTextFieldCombo

local gui = UI.ButtonTextFieldCombo.new("hello Gideros X", nil, 64, 64, nil, Application.TEXTINPUT_CLASS_TEXT)
gui:setDimensions(256, 96)
gui:setColor(0x5c5c5c)
gui:setPosition(50, 50)

local screen=UI.Screen.new() -- needed to add the TextField
screen:ui(gui)

ButtonTextField

local gui = UI.ButtonTextField.new("hello Gideros X", nil, 64, 64, nil, Application.TEXTINPUT_CLASS_TEXT)
gui:setDimensions(256, 96)
gui:setColor(0x5c5c5c)
gui:setPosition(50, 50)

local screen=UI.Screen.new() -- needed to add the TextField
screen:ui(gui)

PasswordField

local gui = UI.PasswordField.new("password", nil, 64, 64, nil, Application.TEXTINPUT_CLASS_TEXT)
gui:setDimensions(256, 96)
gui:setColor(0x5c5c5c)
gui:setPosition(50, 50)

gui:setTipText("enter password")

local screen=UI.Screen.new() -- needed to add the TextField
screen:ui(gui)