Skip to content

UITextInput

继承自

描述

输入框组件

属性

ColorQuadTitleColor
字体颜色
TextVAlignmentTextVAlignment
上下对齐,有向上、中间和向下对齐
TextHAlignmentTextHAlignment
左右对齐,有向左、中间和向右对齐
intMaxLength
限制输入文本长度
intFontSize
字体大小
stringTitle
输入的文本内容
InputModeInput

事件

SBXSignalReturn (bool onReturn)
输入完成时触发

代码示例

lua
local workspace = game:GetService("WorkSpace")
local root= SandboxNode.new('UIRoot', workspace)
local petNameText = SandboxNode.new('UITextInput', root)
--设置节点名字
petNameText.Name = "PetNameText"
--设置节点大小
petNameText.Size = Vector2.new(120, 50)
--设置节点位置
petNameText.Position = Vector2.new(400, 250)
--设置是否可见
petNameText.Visible = true
--设置输入框背景颜色
petNameText.FillColor = ColorQuad.new(97, 151, 230, 255)
--设置文本上下对齐
petNameText.TextVAlignment = Enum.TextVAlignment.Center
--设置文本左右对齐
petNameText.TextHAlignment = Enum.TextHAlignment.Center
--设置输入内容
petNameText.Title = "宠物狼"
--设置输入文本最长长度
petNameText.MaxLength = 20
--设置输入文本字体大小
petNameText.FontSize = 25