Skip to content
InputBox

界面 / InputBox

InputBox Class
​

输入框

Hierarchy ​

Table of contents ​

Properties
​

onTextCommittedMaskCheck: any client
文本提交屏蔽词检测封装
click

Properties
​

onCustomPropertyChange: Readonly<MulticastDelegate<(path: string, value: unknown, oldValue: unknown) => void>> client
监听自定义属性同步事件

Accessors
​

autoWrap(): boolean client
获取是否自动换行
contentColor(): LinearColor client
设置字体内容颜色
defaultFont(): string UIFontFamily client
获取默认字体
errorText(): string client
获取设置错误提示
fallbackFont(): string UIFontFamily client
获取退却字体
fontColor(): LinearColor client
获取当前的字体的颜色
fontLetterSpace(): number client
获取体间距
fontSize(): number client
获取字体大小
glyph(): UIFontGlyph client
获取字体字形
hintString(): string client
获取提示文本内容
inputTextLimit(): InputTextLimit client
获取输入框的输入格式
isRichText(): boolean client
获取是否为富文本
newLineKeyBind(): InsertNewLineType client
插入换行的回车交互,请注意只要触发换行,就无法触发提交文本,枚举可能通过 “
onTextChanged(): MulticastDelegate<(Text: string) => void> client
文本改变事件
onTextCommitted(): MulticastDelegate<(Text: string, CommitMethod: TextCommit, Result?: maskWordCheckResult) => void> client
文本提交事件
outlineColor(): LinearColor client
设置字体描边颜色
outlineSize(): number client
获取字体描边宽度
readOnlyEnable(): boolean client
获取可读性
shadowColor(): LinearColor client
获取字体阴影颜色
shadowOffset(): Vector2 client
获取字体阴影偏移
strikethroughEnable(): boolean client
获取是否开启字体删除线
textAlign(): TextJustify client
获取字体对齐方式
textHeight(): number other
获取文本的高度(文本内容整体的高度,与组件大小无关,受字体属性影响)
textLengthLimit(): number client
获取输入框的字数限制,字数限制不适用与邮箱格式和密码格式
textSingleHeight(): number client
获取文本单行高度(文本单行的高度,与组件大小无关,受字体属性影响)
textVerticalAlign(): TextVerticalJustify client
获取字体垂直对齐方式
underlineEnable(): boolean client
获取是否开启字体下划线
click

Accessors
​

alignPosition(): Readonly<Vector2> client
获取控件的对齐位置,在对齐方式为靠右对齐、靠下对齐、中心对齐时,alignPosition的值与positon不同;
autoSizeHorizontalEnable(): boolean client
获取是否自动水平设置大小
autoSizeVerticalEnable(): boolean client
获取是否自动垂直设置大小
cachedGeometry(): Geometry client
获取上一次的GetTickSpaceGeometry
constraints(): Readonly<UIConstraintAnchors> client
获取控件的布局
desiredSize(): Vector2 client
获取期望大小
enable(): boolean client
是否可用
guid(): string client
获取控件GUID
isHovered(): boolean client
是否是hovered
mouseCursor(): MouseCursor client
获取控件上光标类型
name(): string client
获取名字
paintSpaceGeometry(): Geometry client
获取最后一次用于渲染Widget的几何信息
parent(): Widget client
获取父节点
pivot(): Vector2 client
获取控件锚点位置,这个属性决定了控件图形与锚点的相对位置;(0,0)时,锚点位于控件左上角;(0.5,0.5)时,锚点位于控件正中心
position(): Readonly<Vector2> client
获取控件的位置
renderOpacity(): number client
获取渲染透明度
renderScale(): Vector2 client
获取渲染缩放
renderShear(): Vector2 client
获取渲染错切形变
renderTransformAngle(): number client
获取渲染的角度
renderTransformPivot(): Vector2 client
获取渲染锚点
size(): Vector2 client
获取大小
tickSpaceGeometry(): Geometry client
获取最后一次用于驱动Widget Tick的几何信息
transform(): Readonly<UITransform> client
得到控件的大小和位置
visibility(): SlateVisibility client
获取可见性
visible(): boolean client
是否可见
zOrder(): number client
获取zorder

Methods
​

asyncGetText(): Promise<string> client
异步获取文本接口
deFocus(): void client
设置输入框失焦状态,取消输入状态
focus(): void client
设置输入框聚焦状态,进入可输入状态
setContentColorByHex(inHexString: string): void client
设置输入框的内容颜色,指定 Hex 的颜色文本设定颜色 #05050505
setContentColorDecimal(R: number, G: number, B: number, A: number): void client
设置输入框的内容颜色
setFontColorByHex(inHexString: string): void client
设置文本颜色,指定 Hex 的颜色文本设定颜色 #05050505
setFontColorDecimal(R: number, G: number, B: number, A: number): void client
设置文本颜色
setShadowColorByHex(inHexString: string): void client
设置阴影颜色,指定 Hex 的颜色文本设定颜色 #05050505
setShadowColorDecimal(R: number, G: number, B: number, A: number): void client
设置阴影颜色
setTextJustification(inTextJustification: TextJustify): void client
设置输入框的对齐方式
newObject(parent?: Canvas, inName?: string): InputBox client
创建 InputBox 控件
click

Methods
​

addChild(child: Widget): void client
添加子节点
clone(position: Vector2, Parent?: Widget): Widget client
克隆UI控件及其子节点到指定父控件位置(默认到其父节点)
destroyObject(): void client
立刻移除并销毁 不可以在使用
equal(that: Widget): boolean client
判断是不是同一个对象
findChildByPath(inPath: string): Widget client
通过相对路径查找节点
getChildAt(index: number): Widget client
获取第几位子节点
getChildByName<T: extends Widget<T>>(name: string): T: extends Widget<T> client
通过名字查找节点
getChildrenCount(): number client
获取子节点数量
getCustomProperties(): string[] client
获取所有自定义属性
getCustomProperty<T: extends CustomPropertyType>(propertyName: string): T: extends CustomPropertyType client
获取自定义属性
getCustomPropertyChangeDelegate(property): Readonly<MulticastDelegate<(path: string, value: unknown, oldValue: unknown) => void>> client
给定对象属性修改时触发的事件代理
invalidateLayoutAndVolatility(): void client
立刻触发重新渲染的和排布计算
isValid(): boolean client
判断控件有没有被销毁,是否是有效的控件
removeAllChildren(): void client
清除所有子节点,会销毁UI无法再使用
removeChild(child: Widget): void client
移除节点,会销毁UI无法在使用
removeChildAt(index: number): void client
移除第几个节点,会销毁UI无法再使用
removeObject(): void client
立刻移除并添加到根节点 可以再使用
serialize(): string client
序列化UI控件
setCustomProperty(propertyName: string, value: undefined CustomPropertyType): void client
设置自定义属性
deserialize(Data: string, Parent?: Widget): Widget client
反序列化UI

Properties ​


onTextCommittedMaskCheck
​

• Private onTextCommittedMaskCheck: any client

文本提交屏蔽词检测封装

Param

usage:提交的文本

Param

usage:提交方式

Accessors ​


autoWrap
​

• get autoWrap(): boolean client

• set autoWrap(inAutoWrap): void client

获取是否自动换行

Returns ​

boolean是否自动换行

设置自动换行

Parameters ​

inAutoWrap boolean是否自动换行

contentColor
​

• get contentColor(): LinearColor client

• set contentColor(inContentColor): void client

设置字体内容颜色

Returns ​

LinearColor字体内容颜色,Type.LinearColor类型,数据范围0~1

获取字体内容颜色

Parameters ​

inContentColor LinearColor颜色,Type.LinearColor类型,数据范围0~1

defaultFont
​

• get defaultFont(): string UIFontFamily client

• set defaultFont(inFont): void client

获取默认字体

Returns ​

string UIFontFamily默认字体

设置默认字体

Parameters ​

inFont string UIFontFamily需设置的默认字体

errorText
​

• get errorText(): string client

• set errorText(inText): void client

获取设置错误提示

Returns ​

string错误提示

设置错误提示

Parameters ​

inText string错误提示

fallbackFont
​

• get fallbackFont(): string UIFontFamily client

• set fallbackFont(inFont): void client

获取退却字体

Returns ​

string UIFontFamily退却字体

设置退却字体

Parameters ​

inFont string UIFontFamily需设置的退却字体

fontColor
​

• get fontColor(): LinearColor client

• set fontColor(inColor): void client

获取当前的字体的颜色

Returns ​

LinearColor字体颜色,Type.LinearColor类型,数据范围0~1

设置文本颜色

Parameters ​

inColor LinearColor颜色,Type.LinearColor类型,数据范围0~1

fontLetterSpace
​

• get fontLetterSpace(): number client

• set fontLetterSpace(inLetterSpace): void client

获取体间距

Returns ​

number字体间距

设置字体间距

Parameters ​

inLetterSpace number字体间距

fontSize
​

• get fontSize(): number client

• set fontSize(inSize): void client

获取字体大小

Returns ​

number字体大小

设置字体大小

Parameters ​

inSize number字体大小

glyph
​

• get glyph(): UIFontGlyph client

• set glyph(inGlyph): void client

获取字体字形

Returns ​

UIFontGlyph字体字形

设置字体字形

Parameters ​

inGlyph UIFontGlyph设置的字体字形

hintString
​

• get hintString(): string client

• set hintString(inHintString): void client

获取提示文本内容

Returns ​

string提示文本内容

设置提示内容

Parameters ​

inHintString string提示内容

inputTextLimit
​

• get inputTextLimit(): InputTextLimit client

• set inputTextLimit(inLimit): void client

获取输入框的输入格式

Returns ​

InputTextLimitInputTextLimit { 无限制,限制为整数,限制为小数,限制为数字和字母,限制为密码 }

显示输入框的输入格式

Parameters ​

inLimit InputTextLimit无限制,限制为整数,限制为小数,限制为数字和字母,限制为密码

isRichText
​

• get isRichText(): boolean client

• set isRichText(isRichText): void client

获取是否为富文本

Returns ​

boolean是否为富文本

设置是否为富文本

Parameters ​

isRichTextboolean

newLineKeyBind
​

• get newLineKeyBind(): InsertNewLineType client

• set newLineKeyBind(value): void client

插入换行的回车交互,请注意只要触发换行,就无法触发提交文本,枚举可能通过 “|” 组合在一起设置。判定支不支持需要通过“&”来判定

Returns ​

InsertNewLineType

插入换行的回车交互,请注意只要触发换行,就无法触发提交文本,可以将枚举通过 “|” 组合在一起设置。

Parameters ​

valueInsertNewLineType

onTextChanged
​

• get onTextChanged(): MulticastDelegate<(Text: string) => void> client

文本改变事件

Returns ​

MulticastDelegate<(Text: string) => void>文本改变事件

onTextCommitted
​

• get onTextCommitted(): MulticastDelegate<(Text: string, CommitMethod: TextCommit, Result?: maskWordCheckResult) => void> client

文本提交事件

Returns ​

MulticastDelegate<(Text: string, CommitMethod: TextCommit, Result?: maskWordCheckResult) => void>文本提交事件

outlineColor
​

• get outlineColor(): LinearColor client

• set outlineColor(inOutlineColor): void client

设置字体描边颜色

Returns ​

LinearColor字体描边颜色,Type.LinearColor类型,数据范围0~1

获取字体描边颜色

Parameters ​

inOutlineColor LinearColor描边颜色,Type.LinearColor类型,数据范围0~1

outlineSize
​

• get outlineSize(): number client

• set outlineSize(inOutlineSize): void client

获取字体描边宽度

Returns ​

number字体描边宽度

设置字体描边宽度

Parameters ​

inOutlineSize number宽度

readOnlyEnable
​

• get readOnlyEnable(): boolean client

• set readOnlyEnable(inValue): void client

获取可读性

Returns ​

boolean是否可读

设置可读性

Parameters ​

inValue boolean可读性

shadowColor
​

• get shadowColor(): LinearColor client

• set shadowColor(inShadowColor): void client

获取字体阴影颜色

Returns ​

LinearColor字体阴影颜色,Type.LinearColor类型,数据范围0~1

设置阴影颜色

Parameters ​

inShadowColor LinearColor颜色,Type.LinearColor类型,数据范围0~1

shadowOffset
​

• get shadowOffset(): Vector2 client

• set shadowOffset(inOffset): void client

获取字体阴影偏移

Returns ​

Vector2字体阴影偏移

设置阴影偏移

Parameters ​

inOffset Vector2偏移

strikethroughEnable
​

• get strikethroughEnable(): boolean client

• set strikethroughEnable(inEnableStrikethrough): void client

获取是否开启字体删除线

Returns ​

boolean是否开启字体删除线

设置是否开启字体删除线

Parameters ​

inEnableStrikethrough boolean删除线

textAlign
​

• get textAlign(): TextJustify client

• set textAlign(inTextJustify): void client

获取字体对齐方式

Returns ​

TextJustify字体对齐方式

设置字体对齐方式

Parameters ​

inTextJustify TextJustify对齐方式

textHeight
​

• get textHeight(): number other

获取文本的高度(文本内容整体的高度,与组件大小无关,受字体属性影响)

Returns ​

number文本高度

textLengthLimit
​

• get textLengthLimit(): number client

• set textLengthLimit(inTextLength): void client

获取输入框的字数限制,字数限制不适用与邮箱格式和密码格式

Returns ​

number获取输入框的字数限制

设置当前输入框的字数限制

Parameters ​

inTextLength number字数限制

textSingleHeight
​

• get textSingleHeight(): number client

获取文本单行高度(文本单行的高度,与组件大小无关,受字体属性影响)

Returns ​

number文本单行高度

textVerticalAlign
​

• get textVerticalAlign(): TextVerticalJustify client

• set textVerticalAlign(inTextVerticalJustify): void client

获取字体垂直对齐方式

Returns ​

TextVerticalJustify字体垂直对齐方式

设置字体垂直对齐方式

Parameters ​

inTextVerticalJustify TextVerticalJustify对齐方式

underlineEnable
​

• get underlineEnable(): boolean client

• set underlineEnable(inEnableUnderline): void client

获取是否开启字体下划线

Returns ​

booleantrue:开启,false:关闭

设置是否开启字体下划线

Parameters ​

inEnableUnderline boolean下户线

Methods ​


asyncGetText
​

• asyncGetText(): Promise<string> client

异步获取文本接口

Returns ​

Promise<string>获取当前输入框的文本值,若为正在提交文本,则异步获取

deFocus
​

• deFocus(): void client

设置输入框失焦状态,取消输入状态


focus
​

• focus(): void client

设置输入框聚焦状态,进入可输入状态


setContentColorByHex
​

• setContentColorByHex(inHexString): void client

设置输入框的内容颜色,指定 Hex 的颜色文本设定颜色 #05050505

Parameters ​

inHexString stringHex 颜色字符串 range: 符合 Hex 特点的字符串类型

setContentColorDecimal
​

• setContentColorDecimal(R, G, B, A): void client

设置输入框的内容颜色

Parameters ​

R number图片 R 值。
range:[0, 255] type: 整形
G number图片 G 值。
range:[0, 255] type: 整形
B number图片 B 值。
range:[0, 255] type: 整形
A number图片 透明度。
range:[0, 255] type: 整形

setFontColorByHex
​

• setFontColorByHex(inHexString): void client

设置文本颜色,指定 Hex 的颜色文本设定颜色 #05050505

Parameters ​

inHexString stringHex颜色字符串 range: 符合 Hex 特点的字符串类型

setFontColorDecimal
​

• setFontColorDecimal(R, G, B, A): void client

设置文本颜色

Parameters ​

R number文本 R 值。
range:[0, 255] type: 整形
G number文本 G 值。
range:[0, 255] type: 整形
B number文本 B 值。
range:[0, 255] type: 整形
A number文本 透明度。
range:[0, 255] type: 整形

setShadowColorByHex
​

• setShadowColorByHex(inHexString): void client

设置阴影颜色,指定 Hex 的颜色文本设定颜色 #05050505

Parameters ​

inHexString stringHex 颜色字符串 range: 符合 Hex 特点的字符串类型

setShadowColorDecimal
​

• setShadowColorDecimal(R, G, B, A): void client

设置阴影颜色

Parameters ​

R number阴影 R 值。
range:[0, 255] type: 整形
G number阴影 G 值。
range:[0, 255] type: 整形
B number阴影 B 值。
range:[0, 255] type: 整形
A number阴影 透明度。
range:[0, 255] type: 整形

setTextJustification
​

• setTextJustification(inTextJustification): void client

设置输入框的对齐方式

Parameters ​

inTextJustification TextJustify对齐方式

newObject
​

• Static newObject(parent?, inName?): InputBox client

创建 InputBox 控件

Parameters ​

parent? Canvas创建控件的外parent对象 default:null
inName? string创建控件的名称 default:null range:设置合理的名称即可

Returns ​

InputBox返回创建的对象

当parent和inName与已有的对象相同时,旧的对象会被销毁