界面 / TextBlock
TextBlock Class
文本
Hierarchy
↳
TextBlock
Table of contents
Accessors
autoAdjust(): boolean client |
|---|
| 获取字体是否自适应调整大小:boolean(为True时,文本内容字体大小将自动改变,尽可能大的充满整个文本框,而文本框大小不会变化) |
contentColor(): LinearColor client |
| 获取字体内容颜色 |
fontColor(): LinearColor client |
| 获取字体颜色 |
fontLetterSpace(): number client |
| 获取字体间距 |
fontSize(): number client |
| 获取字体大小 |
glyph(): UIFontGlyph client |
| 获取字体字形 |
isRichText(): boolean client |
| 获取是否为富文本 |
lineHeightPercentage(): number client |
| 获取行高系数 |
maxSize(): number client |
| 获取当前的文本内容 |
minSize(): number client |
| 获取当前的文本内容 |
outlineColor(): LinearColor client |
| 获取字体描边颜色 |
outlineSize(): number client |
| 获取字体描边宽度 |
shadowColor(): LinearColor client |
| 设置字体阴影颜色 |
shadowOffset(): Vector2 client |
| 获取字体阴影颜色 |
strikethroughEnable(): boolean client |
| 获取是否开启字体删除线 |
text(): string <Badge type="tip" text="client" /> |
| 获取当前的文本内容 |
textAlign(): TextJustify client |
| 获取字体对齐方式 |
textHeight(): number other |
| 获取文本的高度(文本内容整体的高度,与组件大小无关,受字体属性影响) |
textHorizontalLayout(): UITextHorizontalLayout client |
| 获取当前字体的水平显示方式 |
textJustification(): TextJustify client |
| 获取字体的对齐方式 |
textSingleHeight(): number client |
| 获取文本单行高度(文本单行的高度,与组件大小无关,受字体属性影响) |
textVerticalAlign(): TextVerticalJustify client |
| 获取字体垂直对齐方式 |
textVerticalJustification(): TextVerticalJustify client |
| 获取字体的垂直对齐方式 |
underlineEnable(): boolean client |
| 返回是否开启字体下划线 |
click
Accessors
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 |
| 获取名字 |
onFocusChange(): Delegate<(absolutionPosition: Vector2) => boolean> client |
| 焦点改变事件 |
onFoucsLost(): Delegate<(absolutionPosition: Vector2) => boolean> client |
| 丢失焦点事件 |
onKeyDownEvent(): Delegate<(absolutionPosition: Vector2, keyEvent: KeyEvent) => boolean> client |
| 按键按下事件 |
onKeyUpEvent(): Delegate<(absolutionPosition: Vector2, keyEvent: KeyEvent) => boolean> client |
| 按键抬起事件 |
onMouseButtonDoubleClick(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 鼠标双击事件 |
onMouseButtonDown(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 鼠标按下事件 |
onMouseButtonUp(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 鼠标抬起事件 |
onMouseEnter(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 鼠标进入控件事件 |
onMouseLeave(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 鼠标离开控件事件 |
onMouseMove(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 鼠标移动事件 |
onMouseWheel(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 鼠标滚轮滚动事件 |
onTouchEnded(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 触摸结束事件 |
onTouchMoved(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 触摸移动事件 |
onTouchStarted(): Delegate<(absolutionPosition: Vector2, pointEvent: PointerEvent) => boolean> client |
| 触摸按下事件 |
paintSpaceGeometry(): Geometry client |
| 获取最后一次用于渲染Widget的几何信息 |
parent(): Widget client |
| 获取父节点 |
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
setFontColorByHex(inHexString: string): void client |
|---|
| 设置字体颜色,指定Hex的颜色文本设定颜色 #05050505 |
setFontColorDecimal(R: number, G: number, B: number, A: number): void client |
| 设置字体颜色 |
setOutlineColorByHex(inHexString: string): void client |
| 设置当前的描边颜色 |
setOutlineColorDecimal(R: number, G: number, B: number, A: number): void client |
| 设置当前的描边颜色 |
setShadowColorByHex(inHexString: string): void client |
| 设置字体的阴影颜色,Shadow Offset必须设值才能看到效果,指定Hex的颜色文本设定颜色 #05050505 |
setShadowColorDecimal(R: number, G: number, B: number, A: number): void client |
| 设置字体的阴影颜色 |
newObject(parent?: Canvas, inName?: string): TextBlock client |
| 创建 TextBlock 控件 |
click
Methods
addChild(child: Widget): void client |
|---|
| 添加子节点 |
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 |
| 获取子节点数量 |
invalidateLayoutAndVolatility(): void client |
| 立刻触发重新渲染的和排布计算 |
removeAllChildren(): void client |
| 清除所有子节点,会销毁UI无法再使用 |
removeChild(child: Widget): void client |
| 移除节点,会销毁UI无法在使用 |
removeChildAt(index: number): void client |
| 移除第几个节点,会销毁UI无法再使用 |
removeObject(): void client |
| 立刻移除并添加到根节点 可以再使用 |
Accessors
autoAdjust
• | • | ||||
|---|---|---|---|---|---|
获取字体是否自适应调整大小:boolean(为True时,文本内容字体大小将自动改变,尽可能大的充满整个文本框,而文本框大小不会变化) Returns
| 设置字体是否自适应调整大小:boolean(为True时,文本内容字体大小将自动改变,尽可能大的充满整个文本框,而文本框大小不会变化) Parameters
|
contentColor
• | • | ||||
|---|---|---|---|---|---|
获取字体内容颜色 Returns
| 设置字体内容颜色 Parameters
|
fontColor
• | • | ||||
|---|---|---|---|---|---|
获取字体颜色 Returns
| 设置字体颜色 Parameters
|
fontLetterSpace
• | • | ||||
|---|---|---|---|---|---|
获取字体间距 Returns
| 设置字体间距 Parameters
|
fontSize
• | • | ||||
|---|---|---|---|---|---|
获取字体大小 Returns
| 设置字体大小 Parameters
|
glyph
• | • | ||||
|---|---|---|---|---|---|
获取字体字形 Returns
| 设置字体字形 Parameters
|
isRichText
• | • | ||||
|---|---|---|---|---|---|
获取是否为富文本 Returns
| 设置富文本 Parameters
|
lineHeightPercentage
• | • | ||||
|---|---|---|---|---|---|
获取行高系数 Returns
| 设置行高系数 Parameters
|
maxSize
• | • | ||||
|---|---|---|---|---|---|
获取当前的文本内容 Returns
| 设置文本内容 Parameters
|
minSize
• | • | ||||
|---|---|---|---|---|---|
获取当前的文本内容 Returns
| 设置文本内容 Parameters
|
outlineColor
• | • | ||||
|---|---|---|---|---|---|
获取字体描边颜色 Returns
| 设置字体描边颜色 Parameters
字体描边颜色 |
outlineSize
• | • | ||||
|---|---|---|---|---|---|
获取字体描边宽度 Returns
| 设置字体描边宽度 Parameters
|
shadowColor
• | • | ||||
|---|---|---|---|---|---|
设置字体阴影颜色 Returns
| 获取字体阴影颜色 Parameters
|
shadowOffset
• | • | ||||
|---|---|---|---|---|---|
获取字体阴影颜色 Returns
| 设置字体阴影偏移 Parameters
|
strikethroughEnable
• | • | ||||
|---|---|---|---|---|---|
获取是否开启字体删除线 Returns
| 设置是否开启字体删除线 Parameters
|
text
• | • | ||||
|---|---|---|---|---|---|
获取当前的文本内容 Returns
| 设置文本内容 Parameters
|
textAlign
• | • | ||||
|---|---|---|---|---|---|
获取字体对齐方式 Returns
| 设置字体对齐方式 Parameters
|
textHeight
• | ||
|---|---|---|
获取文本的高度(文本内容整体的高度,与组件大小无关,受字体属性影响) Returns
|
textHorizontalLayout
• | • | ||||
|---|---|---|---|---|---|
获取当前字体的水平显示方式 Returns
| 设置字体的水平显示方式 Parameters
|
textJustification
• | • | ||||
|---|---|---|---|---|---|
获取字体的对齐方式 Returns
| 设置字体的对齐方式 Parameters
|
textSingleHeight
• | ||
|---|---|---|
获取文本单行高度(文本单行的高度,与组件大小无关,受字体属性影响) Returns
|
textVerticalAlign
• | • | ||||
|---|---|---|---|---|---|
获取字体垂直对齐方式 Returns
| 设置字体垂直对齐方式 Parameters
|
textVerticalJustification
• | • | ||||
|---|---|---|---|---|---|
获取字体的垂直对齐方式 Returns
| 设置字体的垂直对齐方式 Parameters
|
underlineEnable
• | • | ||||
|---|---|---|---|---|---|
返回是否开启字体下划线 Returns
| 设置是否开启字体下划线 Parameters
|
Methods
setFontColorByHex
• setFontColorByHex(inHexString): void client
设置字体颜色,指定Hex的颜色文本设定颜色 #05050505
Parameters
inHexString string | Hex颜色字符串 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: 整数 |
setOutlineColorByHex
• setOutlineColorByHex(inHexString): void client
设置当前的描边颜色
Parameters
inHexString string | 十六进制的字符串 range: 符合 Hex 特点的字符串类型 |
|---|
例如: #05050505
setOutlineColorDecimal
• setOutlineColorDecimal(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
设置字体的阴影颜色,Shadow Offset必须设值才能看到效果,指定Hex的颜色文本设定颜色 #05050505
Parameters
inHexString string | 颜色 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: 整数 |
Shadow Offset 必须设值才能看到效果。
newObject
• Static newObject(parent?, inName?): TextBlock client
创建 TextBlock 控件
Parameters
parent? Canvas | 创建控件的外parent对象 default:null |
|---|---|
inName? string | 创建控件的名称 default:null range:设置合理的名称即可 |
Returns
TextBlock | 返回创建的对象 |
|---|
当parent和inName与已有的对象相同时,旧的对象会被销毁