new PalettePanel(properties)
面板容器;允许在内容区域放置一个子组件并在顶部提供一个标题栏
使用此容器需要注意,不要再用 addView 增加子组件,而是使用 setContentView
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
properties |
any |
<optional> |
Example
// 这个例子中演示了将按钮放置在面板中
var btn1 = new ht.ui.Button();
btn1.setText('button1');
var panel = new ht.ui.Panel();
panel.setContentView(btn1, { marginTop: 10 });
Extends
Methods
-
a(property, value) → {any}
-
Parameters:
Name Type Attributes Description property
any value
any <optional>
Returns:
any- Inherited From:
-
addPropertyChangeListener(listener, scope, ahead) → {void}
-
增加属性事件变化监听函数
Parameters:
Name Type Attributes Description listener
Object 监听器函数
scope
any <optional>
函数域
ahead
boolean <optional>
是否将当前监听器插入到监听器列表开头
Returns:
void- Inherited From:
-
addStyleProperty(property) → {void}
-
追加样式属性,将参数属性加入到样式属性列表中
Parameters:
Name Type Description property
string 属性名
Returns:
void- Inherited From:
-
addToDOM(dom, rect) → {void}
-
将组件加到页面的 DOM 树中;如果没有任何参数,或者只指定第一个参数并且第一个参数为 window,则组件会填满整个浏览器窗口,
并且浏览器窗口大小变化时也会自动刷新组件Parameters:
Name Type Attributes Description dom
HTMLElement <optional>
指定组件的父亲 DOM,如果为空,则加到 body 中
rect
Object <optional>
组件的范围,格式为 {x: x, y: y, width: width, height: height};如果为空,则填满父亲 DOM
Returns:
void- Inherited From:
-
addTool(tool, index) → {void}
-
增加工具按钮
Parameters:
Name Type Attributes Description tool
any 工具按钮配置 json
index
number <optional>
显示顺序
Returns:
void- Inherited From:
-
addView(view, params, index) → {void}
-
将子组件加到容器中
Parameters:
Name Type Attributes Description view
ht.ui.View | ht.ui.TableRow 子组件
params
any <optional>
布局参数;可通过 childView.setLayoutPrams({...}) 提前设置并省略此参数
index
number <optional>
在子组件列表中的插入位置
Returns:
void- Inherited From:
-
addViewListener(listener, scope, ahead) → {void}
-
增加 View 事件监听器,如 invalidate(无效事件)、beginValidate 等事件
Parameters:
Name Type Attributes Description listener
Object 监听器函数
scope
any <optional>
监听器函数域
ahead
boolean <optional>
是否将当前监听器插入到监听器列表开头
Returns:
void- Inherited From:
-
adjustChildHeight(child, height) → {number}
-
布局器计算出子组件的高度,传入此函数进行验证,确保其不会大于 maxSize.height 或小于 minSize.height
返回值会被用于布局子组件Parameters:
Name Type Description child
ht.ui.View 子组件
height
number 验证之前的高度
Returns:
number -验证之后的高度
- Inherited From:
-
adjustChildWidth(child, width) → {number}
-
布局器计算出子组件的宽度,传入此函数进行验证,确保其不会大于 maxSize.width 或小于 minSize.width;
返回值会被用于布局子组件Parameters:
Name Type Description child
ht.ui.View 子组件
width
number 验证之前的宽度
Returns:
number -验证之后的宽度
- Inherited From:
-
adjustTranslateX(value) → {number}
-
调用 setTranslateX 之前调用此函数确保滚动值是合理范围内,如果滚动值不合理,将会被调整并返回
Parameters:
Name Type Description value
number 调整之前的滚动值
Returns:
number -调整后的滚动值
- Inherited From:
-
adjustTranslateY(value) → {number}
-
调用 setTranslateY 之前调用此函数确保滚动值是合理范围内,如果滚动值不合理,将会被调整并返回
Parameters:
Name Type Description value
number 调整之前的滚动值
Returns:
number -调整后的滚动值
- Inherited From:
-
checkPreferredSize(property) → {void}
-
Parameters:
Name Type Description property
string Returns:
void- Inherited From:
-
clear() → {void}
-
删除所有子组件
Returns:
void- Inherited From:
-
containsEvent(e) → {boolean}
-
判断交互事件对象位置是否在组件区域
Parameters:
Name Type Description e
UIEvent Returns:
boolean- Inherited From:
-
disableToolTip() → {void}
-
禁用工具提示,同 setToolTipEnabled
Returns:
void- Inherited From:
-
drawBackground(background, x, y, width, height, dom) → {void}
-
绘制背景
Parameters:
Name Type Attributes Description background
ht.ui.drawable.Drawable <optional>
背景 Drawable
x
number <optional>
起点 x 坐标
y
number <optional>
起点 y 坐标
width
number <optional>
宽度
height
number <optional>
高度
dom
HTMLElement <optional>
指定绘制的目标 DOM
Returns:
void- Inherited From:
-
drawBorder(border, x, y, width, height, dom) → {void}
-
绘制边框
Parameters:
Name Type Attributes Description border
ht.ui.border.Border <optional>
边框对象
x
number <optional>
起点 x 坐标
y
number <optional>
起点 y 坐标
width
number <optional>
宽度
height
number <optional>
高度
dom
HTMLElement <optional>
指定绘制的目标 DOM
Returns:
void- Inherited From:
-
drawHeaderBackground(drawable, x, y, width, height) → {void}
-
绘制标题栏背景
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 图标 Drawable 对象
x
number 绘制范围的 x 坐标
y
number 绘制范围的 y 坐标
width
number 绘制范围的宽度
height
number 绘制范围的高度
Returns:
void- Inherited From:
-
drawIcon(drawable, x, y, width, height) → {void}
-
绘制标题栏图标
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 图标 Drawable 对象
x
number 绘制范围的 x 坐标
y
number 绘制范围的 y 坐标
width
number 绘制范围的宽度
height
number 绘制范围的高度
Returns:
void- Inherited From:
-
drawTitle(g, text, font, color, x, y, width, height) → {void}
-
绘制标题栏文字
Parameters:
Name Type Description g
CanvasRenderingContext2D 画笔对象
text
string 文字内容
font
string 文字字体
color
string 文字颜色
x
number 绘制范围的 x 坐标
y
number 绘制范围的 y 坐标
width
number 绘制范围的宽度
height
number 绘制范围的高度
Returns:
void- Inherited From:
-
drawTool(tool, toolIndex, x, y, width, height) → {void}
-
绘制工具按钮
Parameters:
Name Type Description tool
any 按钮配置 json
toolIndex
number 按钮顺序
x
number 绘制范围的 x 坐标
y
number 绘制范围的 y 坐标
width
number 绘制范围的宽度
height
number 绘制范围的高度
Returns:
void- Inherited From:
-
enableToolTip() → {void}
-
启用工具提示,同 setToolTipEnabled
Returns:
void- Inherited From:
-
figureMaxSize() → {Object}
-
计算 maxSize,maxSize 表示组件的最大尺寸,布局器布局时会考虑此尺寸;
Returns:
Object -maxSize
- Inherited From:
-
figureMinSize() → {Object}
-
计算 minSize,minSize 表示组件的最小尺寸,布局器布局时会考虑此尺寸;
Returns:
Object -minSize
- Inherited From:
-
figurePreferredSize() → {Object}
-
计算 preferredSize,preferredSize 表示组件自身最合适的尺寸,布局器布局时会考虑此尺寸;
如果自定义组件一般需要重写此函数Returns:
Object -preferredSize
- Inherited From:
-
findViewById(id, recursive, skip) → {ht.ui.View}
-
遍历子组件列表根据 id 查找匹配的子组件
Parameters:
Name Type Attributes Description id
string | number 子组件 id
recursive
boolean <optional>
是否递归查找
skip
boolean <optional>
是否跳过 refviewgroup
- Inherited From:
-
fireViewEvent(event) → {void}
-
派发 View 事件
Parameters:
Name Type Description event
string | Object 事件对象;如果是字符串,表示事件类型,函数内自动组装一个事件对象并派发示例:view.fireViewEvent('myevent') 等同于 view.fireViewEvent({kind: 'myevent'})
Returns:
void- Inherited From:
-
fp(property, oldValue, newValue, compareFunc) → {boolean}
-
派发属性变化事件,firePropertyChange 的缩写
Parameters:
Name Type Attributes Description property
string 属性名
oldValue
any 属性变化之前的值
newValue
any 属性变化之后的值
compareFunc
Object <optional>
比较函数,用于比较新值和旧值是否一致,如果一致则不会派发事件
Returns:
boolean -事件是否派发成功
- Inherited From:
-
getActiveCollapseIcon() → {any}
-
获取 Active 状态下合并图标,可以是颜色或者图片等
Returns:
any -合并图标
- Inherited From:
-
getActiveCollapseIconDrawable() → {ht.ui.drawable.Drawable}
-
获取 Active 状态下合并图标的 Drawable 对象
- Inherited From:
-
getActiveExpandIcon() → {any}
-
获取 Active 状态下展开图标,可以是颜色或者图片等
Returns:
any -展开图标
- Inherited From:
-
getActiveExpandIconDrawable() → {ht.ui.drawable.Drawable}
-
获取 Active 状态下展开图标的 Drawable 对象
- Inherited From:
-
getActiveHeaderBackground() → {any}
-
获取 Active 状态下标题栏背景,可以是颜色或者图片等
Returns:
any -标题栏背景
- Inherited From:
-
getActiveHeaderBackgroundDrawable() → {ht.ui.drawable.Drawable}
-
获取 Active 状态下标题栏背景的 Drawable 对象
- Inherited From:
-
getActiveTitleColor() → {string}
-
获取 Active 状态下标题文本颜色
Returns:
string -颜色值
- Inherited From:
-
getAttr(property) → {any}
-
Parameters:
Name Type Description property
string Returns:
any- Inherited From:
-
getBackground() → {any}
-
获取组件的背景,可以是颜色或者图片等
Returns:
any -组件背景
- Inherited From:
-
getBackgroundDrawable() → {ht.ui.drawable.Drawable}
-
获取组件背景的 Drawable 对象
- Inherited From:
-
getBorder() → {ht.ui.border.Border}
-
获取组件的边框
- Inherited From:
-
getBorderBottom() → {number}
-
获取组件边框的底部高度
Returns:
number -组件边框底部高度
- Inherited From:
-
getBorderLeft() → {number}
-
获取组件边框的左侧宽度
Returns:
number -组件边框左侧宽度
- Inherited From:
-
getBorderRadius() → {number|Array.<number>}
-
获取 CSS 边框圆角
Returns:
number | Array.<number> -边框圆角
- Inherited From:
-
getBorderRight() → {number}
-
获取组件边框的右侧宽度
Returns:
number -组件边框右侧宽度
- Inherited From:
-
getBorderTop() → {number}
-
获取组件边框的顶部高度
Returns:
number -组件边框顶部高度
- Inherited From:
-
getBoxShadow() → {string}
-
获取 CSS 阴影值
Returns:
string -阴影值
- Inherited From:
-
getChildAt(event) → {ht.ui.View}
-
获取鼠标事件下的子组件
Parameters:
Name Type Description event
number | MouseEvent | TouchEvent | Object - Inherited From:
-
getChildLayoutParams(child) → {any}
-
获取子组件的 layoutParams
Parameters:
Name Type Description child
ht.ui.View Returns:
any -layoutParams
- Inherited From:
-
getChildren() → {ht.List}
-
获取子组件列表
- Inherited From:
-
getClassName() → {string}
-
获取类名
Returns:
string- Inherited From:
-
getCollapseIcon() → {any}
-
获取正常状态下合并图标,可以是颜色或者图片等
Returns:
any -合并图标
- Inherited From:
-
getCollapseIconDrawable() → {ht.ui.drawable.Drawable}
-
获取正常状态下合并图标的 Drawable 对象
- Inherited From:
-
getCollapseToolIndex() → {number}
-
获取展开合并按钮在工具按钮组中的显示顺序
Returns:
number -显示顺序
- Inherited From:
-
getColorMode() → {string}
-
Returns:
string- Inherited From:
-
getContentBottom() → {number}
-
获取内容底部距离,即底部边框高度加底部内边距高度
Returns:
number -内容底部距离
- Inherited From:
-
getContentDiv() → {HTMLElement}
-
获取内容 div;对于普通组件,contentDiv 里放置了 canvas 画布;对于容器组件,contentDiv 里除了画布,还有所有的子组件
Returns:
HTMLElement -内容 div
- Inherited From:
-
getContentHeight() → {number}
-
获取内容高度,即组件高度减去边框高度和上下内边距高度
Returns:
number -内容高度
- Inherited From:
-
getContentLeft() → {number}
-
获取内容左侧距离,即左侧边框宽度加左侧内边距宽度
Returns:
number -内容左侧距离
- Inherited From:
-
getContentPadding() → {number|Array.<number>}
-
获取内容组件到面板边缘的距离;如果是数字,说明四边使用相同的距离;如果是数组,则格式为:[上边距离, 右边距离, 下边距离, 左边距离]
Returns:
number | Array.<number>- Inherited From:
-
getContentPoint(event) → {Object}
-
获取内容坐标点;此坐标与内边距和边框无关,是从内容区域左上角开始计算
Parameters:
Name Type Description event
any 交互事件对象(如鼠标事件对象)
Returns:
Object -内容坐标点,包含 x、y 坐标
- Inherited From:
-
getContentRight() → {number}
-
获取内容右侧距离,即右侧边框宽度加右侧内边距宽度
Returns:
number -内容右侧距离
- Inherited From:
-
getContentTop() → {number}
-
获取内容顶部距离,即顶部边框高度加顶部内边距高度
Returns:
number -内容顶部距离
- Inherited From:
-
getContentView() → {ht.ui.View}
-
获取面板中的子组件
- Inherited From:
-
getContentWidth() → {number}
-
获取内容宽度,即组件宽度减去边框宽度和左右内边距宽度
Returns:
number -内容宽度
- Inherited From:
-
getContextMenu() → {ht.ui.ContextMenu}
-
获取绑定的右键菜单
- Inherited From:
-
getCurrentTitleColor(state) → {string}
-
根据标题栏状态,返回相应的颜色(normalTitleColor 或 hoverTitleColor 或 activeTitleColor);可重写自定义
Parameters:
Name Type Attributes Description state
string <optional>
状态,如果未指定,使用 panel.getHeaderState()
Returns:
string -颜色值
- Inherited From:
-
getCursor() → {string}
-
获取鼠标样式(CSS 格式)
Returns:
string -鼠标样式
- Inherited From:
-
getDisabledBackground() → {any}
-
组件被禁用时,遮罩的背景;这个值被设置到遮罩 div 的 background 样式上,因此可以使用所有 CSS 支持的 background 类型
Returns:
any -遮罩背景
- Inherited From:
-
getDOMProperties() → {any}
-
获取 DOM 属性映射表,格式为:{'width': true ...};这些属性发生变化才会更新 DOM 结构,否则只需要绘制内容即可
Returns:
any -DOM 属性映射表
- Inherited From:
-
getErrorMessage() → {string}
-
获取错误信息
Returns:
string -错误信息
- Inherited From:
-
getExpandIcon() → {any}
-
获取正常状态下展开图标,可以是颜色或者图片等
Returns:
any -展开图标
- Inherited From:
-
getExpandIconDrawable() → {ht.ui.drawable.Drawable}
-
获取正常状态下展开图标的 Drawable 对象
- Inherited From:
-
getHeaderBackground() → {any}
-
获取正常状态下标题栏背景,可以是颜色或者图片等
Returns:
any -标题栏背景
- Inherited From:
-
getHeaderBackgroundDrawable() → {ht.ui.drawable.Drawable}
-
获取正常状态下标题栏背景的 Drawable 对象
- Inherited From:
-
getHeaderHeight() → {number}
-
获取标题栏高度
Returns:
number -标题栏高度
- Inherited From:
-
getHeaderPaddingLeft() → {number}
-
获取标题栏左侧内边距
Returns:
number -左侧内边距
- Inherited From:
-
getHeaderPaddingRight() → {number}
-
获取标题栏右侧内边距
Returns:
number -右侧内边距
- Inherited From:
-
getHeaderState() → {string}
-
获取标题栏状态
Returns:
string -标题栏状态,值可能为:'normal'|'hover'|'active'
- Inherited From:
-
getHeight() → {number}
-
获取组件的高度
Returns:
number -组件高度
- Inherited From:
-
getHoverCollapseIcon() → {any}
-
获取 Hover 状态下合并图标,可以是颜色或者图片等
Returns:
any -合并图标
- Inherited From:
-
getHoverCollapseIconDrawable() → {ht.ui.drawable.Drawable}
-
获取 Hover 状态下合并图标的 Drawable 对象
- Inherited From:
-
getHoverExpandIcon() → {any}
-
获取 Hover 状态下展开图标,可以是颜色或者图片等
Returns:
any -展开图标
- Inherited From:
-
getHoverExpandIconDrawable() → {ht.ui.drawable.Drawable}
-
获取 Hover 状态下展开图标的 Drawable 对象
- Inherited From:
-
getHoverHeaderBackground() → {any}
-
获取 Hover 状态下标题栏背景,可以是颜色或者图片等
Returns:
any -标题栏背景
- Inherited From:
-
getHoverHeaderBackgroundDrawable() → {ht.ui.drawable.Drawable}
-
获取 Hover 状态下标题栏背景的 Drawable 对象
- Inherited From:
-
getHoverTitleColor() → {string}
-
获取 Hover 状态下标题文本颜色
Returns:
string -颜色值
- Inherited From:
-
getIcon() → {any}
-
获取标题栏图标,可以是颜色或者图片等
Returns:
any -图标
- Inherited From:
-
getIconDrawable() → {ht.ui.drawable.Drawable}
-
获取标题栏图标的 Drawable 对象
- Inherited From:
-
getIconHeight() → {number}
-
获取标题栏图标高度
Returns:
number -图标高度
- Inherited From:
-
getIconTitleGap() → {number}
-
获取标题栏图文字和图标之间的距离
Returns:
number -间距值
- Inherited From:
-
getIconWidth() → {number}
-
获取标题栏图标宽度
Returns:
number -图标宽度
- Inherited From:
-
getId() → {any}
-
获取唯一标识,根据标识可快速查找到组件
Returns:
any -唯一标识
- Inherited From:
-
getInteractorClasses() → {Array.<string>}
-
获取交互器类名数组
Returns:
Array.<string> -交互器类名数组
- Inherited From:
-
getLayoutParams(key) → {any}
-
获取布局参数
Parameters:
Name Type Attributes Description key
string <optional>
布局参数中的 key
Returns:
any -如果指定 key 参数返回布局参数中 key 对应的值,否则返回整个布局参数对象
- Inherited From:
-
getMargin() → {number|Array.<number>}
-
获取组件外边距,如果是数字,说明四边使用相同的外边距;如果是数组,则格式为:[上边距, 右边距, 下边距, 左边距]
Returns:
number | Array.<number> -外边距
- Inherited From:
-
getMarginBottom() → {number}
-
获取组件底部外边距高度
Returns:
number -底部外边距高度
- Inherited From:
-
getMarginRight() → {number}
-
获取组件右侧外边距宽度
Returns:
number -右侧外边距宽度
- Inherited From:
-
getMarginTop() → {number}
-
获取组件顶部外边距高度
Returns:
number -顶部外边距高度
- Inherited From:
-
getMarignLeft() → {number}
-
获取组件左侧外边距宽度
Returns:
number -左侧外边距宽度
- Inherited From:
-
getMatchedStyles() → {any}
-
获取组件匹配到的样式
Returns:
any- Inherited From:
-
getMaxSize() → {Object}
-
获取 maxSize,maxSize 表示组件自身最合适的尺寸;
如果用户没有设置,则调用 figureMaxSize 计算Returns:
Object -maxSize
- Inherited From:
-
getMaxSizeProperties() → {any}
-
获取 maxSize 属性映射表,格式为:{'border': true ...};这些属性变化会重新计算 maxSize
Returns:
any -maxSize 属性映射表
- Inherited From:
-
getMinSize() → {Object}
-
获取 minSize,minSize 表示组件的最小尺寸;
如果用户没有设置,则调用 figureMinSize 计算Returns:
Object -minSize
- Inherited From:
-
getMinSizeProperties() → {any}
-
获取 minSize 属性映射表,格式为:{'border': true ...};这些属性变化会重新计算 minSize
Returns:
any -minSize 属性映射表
- Inherited From:
-
getPadding() → {number|Array.<number>}
-
获取组件内边距,如果是数字,说明四边使用相同的内边距;如果是数组,则格式为:[上边距, 右边距, 下边距, 左边距]
Returns:
number | Array.<number> -内边距
- Inherited From:
-
getPaddingBottom() → {number}
-
获取组件底部内边距高度
Returns:
number -底部内边距高度
- Inherited From:
-
getPaddingLeft() → {number}
-
获取组件左侧内边距宽度
Returns:
number -左侧内边距宽度
- Inherited From:
-
getPaddingRight() → {number}
-
获取组件右侧内边距宽度
Returns:
number -右侧内边距宽度
- Inherited From:
-
getPaddingTop() → {number}
-
获取组件顶部内边距高度
Returns:
number -顶部内边距高度
- Inherited From:
-
getParent() → {ht.ui.ViewGroup}
-
获取父容器
- Inherited From:
-
getPopover() → {ht.ui.Popover}
-
获取弹框组件
- Inherited From:
-
getPopoverPlacements() → {Array.<string>}
-
获取弹框组件的弹出位置
Returns:
Array.<string> -弹出位置
- Inherited From:
-
getPopoverTrigger() → {string}
-
获取弹框触发器
Returns:
string -弹框触发器,值为:click|hover
- Inherited From:
-
getPreferredSize() → {Object}
-
获取 preferredSize,preferredSize 表示组件自身最合适的尺寸,布局器布局时会考虑此尺寸;
如果用户没有设置,则调用 figurePreferredSize 计算Returns:
Object -preferredSize
- Inherited From:
-
getPreferredSizeProperties() → {any}
-
获取 preferredSize 属性映射表,格式为:{'border': true ...};这些属性变化会重新计算 preferredSize
Returns:
any -preferredSize 属性映射表
- Inherited From:
-
getPropertyValue(name) → {any}
-
取组件的某个属性的原始值;
不要直接去取私有变量,例如 padding,不要直接取 _padding 私有变量,而是应该使用此函数取值;
此函数取值顺序:
先取 _padding 私有变量
如果为 undefind,再去取样式表中取值
如果为 undefied,再取 __padding 私有变量Parameters:
Name Type Description name
string 属性名
Returns:
any -属性值
- Inherited From:
Example
// 这段代码演示了覆盖 getPadding 函数,先取出旧的 padding,再 +2 并返回 button.getPadding = function() { var oldPadding = this.getPropertyValue('padding'); oldPadding += 2; return oldPadding; }
-
getRootCanvas() → {HTMLCanvasElement}
-
获取根 Canvas,这个 Canvas 用来绘制背景、边框、内容等
Returns:
HTMLCanvasElement -Canvas DOM 对象
- Inherited From:
-
getRootContext(dom, ignoreCache) → {CanvasRenderingContext2D}
-
获取默认的 canvas 画布的画笔对象,或者获取参数 DOM 对象的画笔;
此函数在绘制背景、边框和自定义组件的情况下经常使用Parameters:
Name Type Attributes Description dom
HTMLElement <optional>
指定目标 DOM,通常是个 canvas 类型的 DOM 对象
ignoreCache
boolean <optional>
Returns:
CanvasRenderingContext2D -画笔对象
- Inherited From:
-
getScrollBarActiveSize() → {number}
-
获取滚动条感应区域的大小
Returns:
number -滚动条感应区域的大小
- Inherited From:
-
getScrollBarColor() → {string}
-
获取滚动条颜色
Returns:
string -颜色值
- Inherited From:
-
getScrollBarMinLength() → {number}
-
获取滚动条最小长度
Returns:
number -滚动条最小长度
- Inherited From:
-
getScrollBarMode() → {string}
-
获取滚动条模式,支持 'on'|'off'|'auto'|'hidden'
Returns:
string -滚动条模式
- Inherited From:
-
getScrollBarSize() → {number}
-
获取滚动条大小(横向滚动条的高度,纵向滚动条的宽度)
Returns:
number -滚动条大小
- Inherited From:
-
getScrollBarTimeout() → {number}
-
获取滚动条显示时间,超过时间后滚动条将隐藏
Returns:
number -滚动条显示时间
- Inherited From:
-
getScrollRect() → {Object}
-
获取滚动范围,即内容区域
Returns:
Object -内容区域,格式为:{x: x, y: y, width: width, height: height}
- Inherited From:
-
getStyle(property) → {any}
-
Parameters:
Name Type Description property
string Returns:
any- Inherited From:
-
getStyleProperties() → {any}
-
获取样式属性映射表,格式为:{'padding': true, 'border': true ...}
Returns:
any -样式属性映射表
- Inherited From:
-
getStyleValue(property) → {any}
-
获取样式属性对应的样式值
Parameters:
Name Type Description property
string 属性名
Returns:
any -样式值
- Inherited From:
-
getTitle() → {string}
-
获取标题文本
Returns:
string -标题文本
- Inherited From:
-
getTitleColor() → {string}
-
获取正常状态下标题文本颜色
Returns:
string -颜色值
- Inherited From:
-
getTitleFont() → {string}
-
获取标题文本字体
Returns:
string -标题文本字体
- Inherited From:
-
getToolAt(event) → {any}
-
获取事件对象下的工具按钮
Parameters:
Name Type Description event
any 事件对象
Returns:
any -工具按钮配置 json
- Inherited From:
-
getToolGap() → {number}
-
获取标题栏工具按钮之间的距离
Returns:
number -间距值
- Inherited From:
-
getToolHeight() → {number}
-
获取标题栏工具按钮高度
Returns:
number -高度值
- Inherited From:
-
getToolIndex(tool) → {number}
-
获取工具按钮的顺序
Parameters:
Name Type Description tool
any 工具按钮配置 json
Returns:
number -显示顺序
- Inherited From:
-
getTools() → {Array.<any>}
-
获取标题栏的工具按钮
Returns:
Array.<any> -工具按钮数组,格式为:[{icon: 'icon', onClick: function(e) {} }, {icon: 'icon1', onClick: function(e) {} }]
- Inherited From:
-
getToolsPosition() → {string}
-
获取标题栏工具按钮的位置
Returns:
string -工具按钮位置,值为 left|right
- Inherited From:
-
getToolTip(event) → {string}
-
获取工具提示文本内容
Parameters:
Name Type Attributes Description event
any <optional>
Returns:
string -工具提示文本内容
- Inherited From:
-
getToolWidth() → {number}
-
获取标题栏工具按钮宽度
Returns:
number -宽度值
- Inherited From:
-
getTranslateX() → {number}
-
获取水平滚动值
Returns:
number -水平滚动值
- Inherited From:
-
getTranslateY() → {number}
-
获取垂直滚动值
Returns:
number -垂直滚动值
- Inherited From:
-
getView() → {HTMLElement}
-
获取组件最根层的 div
Returns:
HTMLElement -组件 div
- Inherited From:
-
getViewPoint(event) → {Object}
-
获取组件坐标点;从组件的左上角开始计算
Parameters:
Name Type Description event
any 交互事件对象(如鼠标事件对象)
Returns:
Object -组件坐标点,包含 x、y 坐标
- Inherited From:
-
getViewRect() → {Object}
-
获取视窗范围,即可视区域
Returns:
Object -可见区域,格式为:{x: x, y: y, width: width, height: height}
- Inherited From:
-
getVisibleChildren() → {ht.List}
-
获取可见的子组件列表
- Inherited From:
-
getWidth() → {number}
-
获取组件的宽度
Returns:
number -组件宽度
- Inherited From:
-
getX() → {number}
-
获取组件的 x 坐标
Returns:
number -x 坐标
- Inherited From:
-
getY() → {number}
-
获取组件的 y 坐标
Returns:
number -y 坐标
- Inherited From:
-
getZIndex() → {number}
-
获取组件的堆叠顺序
Returns:
number -堆叠顺序
- Inherited From:
-
getZoom() → {number}
-
获取缩放值
Returns:
number -缩放值
- Inherited From:
-
getZoomAnchor() → {Array.<number>}
-
获取缩放锚点
Returns:
Array.<number> -锚点数组
- Inherited From:
-
hasContentCanvas() → {boolean}
-
判断组件是否有私有 canvas
Returns:
boolean -组件是否有私有 canvas
- Inherited From:
-
hasFocus() → {boolean}
-
判断焦点是否在组件上
Returns:
boolean -焦点是否在组件上
- Inherited From:
-
headerHitTest(event) → {boolean}
-
判断是否点击中标题栏
Parameters:
Name Type Description event
any 事件对象
Returns:
boolean -是否点击中分隔条
- Inherited From:
-
hidePopover() → {void}
-
隐藏弹框组件
Returns:
void- Inherited From:
-
hideToolTip() → {void}
-
隐藏 toolTip
Returns:
void- Inherited From:
-
initView(canvas) → {void}
-
初始化组件的 DOM 结构
Parameters:
Name Type Attributes Description canvas
boolean <optional>
是否创建一个私有的 canvas 用来绘制私有内容,一般情况下在默认的 canvas 中绘制就可以,不需要此参数
Returns:
void- Inherited From:
-
invalidate(forceLayoutChildren) → {void}
-
使组件无效化
Parameters:
Name Type Attributes Description forceLayoutChildren
boolean <optional>
是否强制刷新子组件(即使子组件没有无效标记)
Returns:
void- Inherited From:
-
invalidateDOM() → {void}
-
设置重新布局 DOM 标记并调用 invalidate, 组件下次刷新时会强制更新 DOM
Returns:
void- Inherited From:
-
isCloseToHScrollBar(e) → {void}
-
事件的坐标是否接近水平滚动条(接近的范围由 scrollBarActiveSize 决定)
Parameters:
Name Type Description e
MouseEvent | TouchEvent 鼠标或 Touch 事件对象
Returns:
void- Inherited From:
-
isCloseToVScrollBar(e) → {void}
-
事件的坐标是否接近垂直滚动条(接近的范围由 scrollBarActiveSize 决定)
Parameters:
Name Type Description e
MouseEvent | TouchEvent 鼠标或 Touch 事件对象
Returns:
void- Inherited From:
-
isCollapsable() → {boolean}
-
判断面板是否可合并;如果为 true,在工具按钮中显示展开合并按钮
Returns:
boolean -是否可展开合并
- Inherited From:
-
isDescendantOf(viewGroup) → {boolean}
-
判断当前组件是否是参数容器的子孙组件
Parameters:
Name Type Description viewGroup
ht.ui.ViewGroup 容器
Returns:
boolean- Inherited From:
-
isDisabled() → {boolean}
-
组件是否被禁用
Returns:
boolean -是否被禁用
- Inherited From:
-
isExpanded() → {boolean}
-
判断面板是否处于展开状态
Returns:
boolean -面板是否展开
- Inherited From:
-
isFloatLayout() → {boolean}
-
Returns:
boolean- Inherited From:
-
isFocusable() → {boolean}
-
组件是否可以获取焦点
Returns:
boolean -是否可获取焦点
- Inherited From:
-
isHeaderVisible() → {boolean}
-
判断标题栏是否可见
Returns:
boolean -是否可见
- Inherited From:
-
isHScrollable() → {boolean}
-
判断容器是否可以水平滚动(即 scrollRect.width > viewRect.width)
Returns:
boolean -是否可以水平滚动
- Inherited From:
-
isInDOM() → {boolean}
-
判断组件是否在 DOM 树中
Returns:
boolean -组件是否在 DOM 树中
- Inherited From:
-
isMaxSizeSet() → {boolean}
-
判断 maxSize 是否被设置(如果为 true, 组件不再调用 figureMaxSize 自动计算)
Returns:
boolean -maxSize 是否被设置
- Inherited From:
-
isMinSizeSet() → {boolean}
-
判断 minSize 是否被设置(如果为 true, 组件不再调用 figureMinSize 自动计算)
Returns:
boolean -minSize 是否被设置
- Inherited From:
-
isPreferredSizeSet() → {boolean}
-
判断 preferredSize 是否被设置(如果为 true, 组件不再调用 figurePreferredSize 自动计算)
Returns:
boolean -preferredSize 是否被设置
- Inherited From:
-
isRedrawOnFocus() → {boolean}
-
判断组件获取或失去焦点时,是否重绘自身
Returns:
boolean -是否重绘自身
- Inherited From:
-
isSelfViewEvent(event) → {boolean}
-
判断鼠标事件是否发生在组件自身上,例如容器的 div 上监听到一个原生的鼠标点击事件,此事件可能来自容器,也可能来自子组件的冒泡传播;
如果自定义组件,并且改变了组件的 DOM 结构,需要重写此函数Parameters:
Name Type Description event
any 事件对象
Returns:
boolean -事件是否发生在自身 DOM 上
- Inherited From:
-
isStyleProperty(property) → {boolean}
-
判断属性是否是样式属性
Parameters:
Name Type Description property
string 属性名
Returns:
boolean -是否是样式属性
- Inherited From:
-
isToolTipEnabled() → {boolean}
-
是否启用工具提示
Returns:
boolean -是否启用工具提示
- Inherited From:
-
isVisible() → {boolean}
-
判断组件是否可见
Returns:
boolean -组件是否可见
- Inherited From:
-
isVScrollable() → {boolean}
-
判断容器是否可以垂直滚动(即 scrollRect.height > viewRect.height)
Returns:
boolean -是否可以垂直滚动
- Inherited From:
-
iv(forceLayoutChildren) → {void}
-
使组件无效化
Parameters:
Name Type Attributes Description forceLayoutChildren
boolean <optional>
是否强制刷新子组件(即使子组件没有无效标记)
Returns:
void- Inherited From:
-
layoutChild(child, x, y, width, height) → {void}
-
布局子组件,设置组件的 x、y 坐标以及宽高并调用子组件的 validate;
如果自定义布局器,一般需要在 validateImpl 函数中调用此函数对子组件进行布局Parameters:
Name Type Description child
ht.ui.View 要布局的子组件
x
number 组件的 x 坐标
y
number 组件的 y 坐标
width
number 组件的宽度
height
number 组件的高度
Returns:
void- Inherited From:
-
layoutDOM(x, y, width, height) → {void}
-
重新调整组件的 DOM 结构布局,设置坐标、宽高以及内边距等
Parameters:
Name Type Attributes Description x
number 组件的 x 坐标
y
number <optional>
组件的 y 坐标
width
number <optional>
组件宽度
height
number <optional>
组件高度
Returns:
void- Inherited From:
-
makeDisabled(disabled, disabledDiv) → {void}
-
设置禁用组件样式,默认会将 disabedDiv 插入到组件内部
Parameters:
Name Type Description disabled
boolean 是否禁用
disabledDiv
HTMLElement 遮罩 div
Returns:
void- Inherited From:
-
mp(listener, scope, ahead) → {void}
-
增加属性事件变化监听函数,addPropertyChangeListener 的缩写
Parameters:
Name Type Attributes Description listener
Object 监听器函数
scope
any <optional>
函数域
ahead
boolean <optional>
是否将当前监听器插入到监听器列表开头
Returns:
void- Inherited From:
-
off(name, listener, scope) → {void}
-
删除事件监听
Parameters:
Name Type Attributes Description name
string 属性名,p: 开头(如 p:value),表示监听属性变化事件;d: 开头(如 d:mousedown) 表示监听原生 DOM 事件;其它情况当作 viewEvent 处理
listener
Object scope
any <optional>
监听器函数域
Returns:
void- Inherited From:
-
on(name, listener, scope, ahead) → {void}
-
增加事件监听
Parameters:
Name Type Attributes Description name
string 属性名,p: 开头(如 p:value),表示监听的是属性变化事件;d: 开头(如 d:mousedown) 表示监听原生 DOM 事件;其它情况当作 viewEvent 处理
listener
Object scope
any <optional>
监听器函数域
ahead
boolean <optional>
如果是 DOM 事件,表示 useCapture;否则表示是否将当前监听器插入到监听器列表开头
Returns:
void- Inherited From:
-
onOnce(name, listener, scope, ahead) → {void}
-
增加一次性事件监听(监听器执行一次,然后马上被删除)
Parameters:
Name Type Attributes Description name
string 属性名,p: 开头(如 p:value),表示监听属性变化事件;d: 开头(如 d:mousedown) 表示监听原生 DOM 事件;其它情况当作 viewEvent 处理
listener
Object scope
any <optional>
监听器函数域
ahead
boolean <optional>
如果是 DOM 事件,表示 useCapture;否则表示是否将当前监听器插入到监听器列表开头
Returns:
void- Inherited From:
-
onPropertyChanged(e) → {void}
-
属性变化回调
Parameters:
Name Type Description e
Object Returns:
void- Inherited From:
-
processValidate() → {void}
-
绘制组件边框、背景及调用 validateImpl;此函数在 validate 中被调用
Returns:
void- Inherited From:
-
redraw(forceLayoutChildren) → {void}
-
设置所有的重绘标记包括重绘 canvas 标记、重绘 border 标记和重新布局 DOM 标记 并调用 iv
Parameters:
Name Type Attributes Description forceLayoutChildren
boolean <optional>
是否强制刷新子组件(即使子组件没有无效标记)
Returns:
void- Inherited From:
-
removeFromDOM() → {void}
-
将组件从页面的 DOM 树中删除;如果要删除通过 addToDOM 添加到页面的组件,应使用此函数,以免内存泄漏
Returns:
void- Inherited From:
-
removePropertyChangeListener(listener, scope) → {void}
-
删除属性事件变化监听器
Parameters:
Name Type Attributes Description listener
Object 监听器函数
scope
any <optional>
函数域
Returns:
void- Inherited From:
-
removeStyleProperty(property) → {void}
-
删除样式属性,将参数属性从样式属性列表中移除
Parameters:
Name Type Description property
string 属性名
Returns:
void- Inherited From:
-
removeToolAt(index) → {void}
-
删除指定下标的工具按钮
Parameters:
Name Type Description index
number 工具按钮的下标
Returns:
void- Inherited From:
-
removeView(view) → {void}
-
将子组件从容器中删除
Parameters:
Name Type Description view
ht.ui.View 要删除的子组件
Returns:
void- Inherited From:
-
removeViewAt(index) → {void}
-
删除容器子组件列表中对应下标为 index 的子组件
Parameters:
Name Type Description index
number 子组件下标
Returns:
void- Inherited From:
-
removeViewListener(listener, scope) → {void}
-
删除 View 事件监听器
Parameters:
Name Type Attributes Description listener
Object 监听器函数
scope
any <optional>
监听器函数域
Returns:
void- Inherited From:
-
requestFocus() → {void}
-
请求获取焦点
Returns:
void- Inherited From:
-
resetTranslate() → {any}
-
Returns:
any- Inherited From:
-
set(properties) → {void}
-
批量设置组件属性
Parameters:
Name Type Description properties
any 格式示范:{ background: 'red', border: new ht.ui.border.LineBorder(1, 'red'), padding: 20 }
Returns:
void- Inherited From:
-
setActiveCollapseIcon(icon) → {void}
-
设置 Active 状态下合并图标
Parameters:
Name Type Description icon
any 合并图标,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setActiveCollapseIconDrawable(drawable) → {void}
-
设置 Active 状态下合并图标的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 合并图标
Returns:
void- Inherited From:
-
setActiveExpandIcon(icon) → {void}
-
设置 Active 状态下展开图标
Parameters:
Name Type Description icon
any 展开图标,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setActiveExpandIconDrawable(drawable) → {void}
-
设置 Active 状态下展开图标的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 展开图标
Returns:
void- Inherited From:
-
setActiveHeaderBackground(background) → {void}
-
设置 Active 状态下标题栏背景
Parameters:
Name Type Description background
any 标题栏背景,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setActiveHeaderBackgroundDrawable(drawable) → {void}
-
设置 Active 状态下标题栏背景的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 标题栏背景
Returns:
void- Inherited From:
-
setActiveTitleColor(color) → {void}
-
设置 Active 状态下标题文本颜色
Parameters:
Name Type Description color
string 颜色值
Returns:
void- Inherited From:
-
setAttr(property, value) → {void}
-
Parameters:
Name Type Description property
string value
any Returns:
void- Inherited From:
-
setBackground(background) → {void}
-
设置组件的背景,可以是颜色或者图片等;此值最终会被转换为 Drawable 对象
Parameters:
Name Type Description background
any 颜色值、图片名、图片路径、矢量对象等
Returns:
void- Inherited From:
-
setBackgroundDrawable(drawable) → {void}
-
设置组件的背景 Drawable 对象;组件渲染时优先使用此 Drawable 对象,如果为空,再用 background 转换
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable Drawable 对象
Returns:
void- Inherited From:
-
setBorder(border) → {void}
-
设置组件的边框
Parameters:
Name Type Description border
ht.ui.border.Border 组件边框
Returns:
void- Inherited From:
-
setBorderRadius(radius) → {void}
-
设置 CSS 边框圆角
Parameters:
Name Type Description radius
number | Array.<number> 边框圆角;如果是数组,则表示[左上角圆角、右上角圆角、右下角圆角、左下角圆角]
Returns:
void- Inherited From:
-
setBoxShadow(boxShadow) → {void}
-
设置 CSS 阴影值
Parameters:
Name Type Description boxShadow
string 阴影值
Returns:
void- Inherited From:
-
setChildren(children) → {void}
-
设置子组件,会覆盖容器原有子组件
Parameters:
Name Type Description children
Array.<any> 子组件集合
Returns:
void- Inherited From:
-
setCollapsable(collapsable) → {void}
-
设置面板是否可合并
Parameters:
Name Type Description collapsable
boolean 是否可展开合并;如果为 true,在工具按钮组中显示展开合并按钮
Returns:
void- Inherited From:
-
setCollapseIcon(icon) → {void}
-
设置正常状态下合并图标
Parameters:
Name Type Description icon
any 合并图标,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setCollapseIconDrawable(drawable) → {void}
-
设置正常状态下合并图标的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 合并图标
Returns:
void- Inherited From:
-
setCollapseToolIndex(index) → {void}
-
设置展开合并按钮在工具按钮组中的显示顺序
Parameters:
Name Type Description index
number 显示顺序
Returns:
void- Inherited From:
-
setColorMode(mode) → {void}
-
Parameters:
Name Type Description mode
string Returns:
void- Inherited From:
-
setContentPadding(contentPadding) → {void}
-
设置内容组件到面板边缘的距离;如果是数字,说明四边使用相同的距离;如果是数组,则格式为:[上边距离, 右边距离, 下边距离, 左边距离]
Parameters:
Name Type Description contentPadding
number | Array.<number> Returns:
void- Inherited From:
-
setContentView(view, layoutParams) → {void}
-
设置面板中的子组件
Parameters:
Name Type Attributes Description view
ht.ui.View 子组件
layoutParams
any <optional>
布局参数;可通过 childView.setLayoutPrams({...}) 提前设置并省略此参数
Returns:
void- Inherited From:
-
setContextMenu(contextMenu) → {void}
-
设置绑定的右键菜单
Parameters:
Name Type Description contextMenu
ht.ui.ContextMenu 右键菜单
Returns:
void- Inherited From:
-
setCursor(cursor) → {void}
-
设置鼠标样式(CSS 格式)
Parameters:
Name Type Description cursor
string 鼠标样式
Returns:
void- Inherited From:
-
setDisabled(disabled) → {void}
-
设置组件是否被禁用
Parameters:
Name Type Description disabled
string | boolean 是否被禁用;如果为字符串,组件除了被禁用,disabledDiv 还会被设置相应的 CSS 样式名
Returns:
void- Inherited From:
-
setDisabledBackground(background) → {void}
-
设置组件被禁用时,遮罩的背景;这个值被设置到遮罩 div 的 background 样式上,因此可以使用所有 CSS 支持的 background 类型
Parameters:
Name Type Description background
string 遮罩背景
Returns:
void- Inherited From:
Example
// 设置一个居中的 gif 图片 作为背景 view.setDisabledBackground('url(a.gif) no-repeat 50% 50%');
-
setErrorMessage(message, params) → {ht.ui.Popover}
-
设置错误信息
Parameters:
Name Type Description message
string 错误信息
params
any ErrorMessagePopover 组件的属性配置,如 { placements: ['top'] } 将错误提示显示在上方
- Inherited From:
-
setExpanded(expanded) → {void}
-
设置面板展开合并状态
Parameters:
Name Type Description expanded
boolean 面板是否展开
Returns:
void- Inherited From:
-
setExpandIcon(icon) → {void}
-
设置正常状态下展开图标
Parameters:
Name Type Description icon
any 展开图标,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setExpandIconDrawable(drawable) → {void}
-
设置正常状态下展开图标的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 展开图标
Returns:
void- Inherited From:
-
setFloatLayout(floatLayout) → {void}
-
Parameters:
Name Type Description floatLayout
boolean Returns:
void- Inherited From:
-
setFocusable(focusable) → {void}
-
设置组件是否可以获取焦点
Parameters:
Name Type Description focusable
boolean 是否可获取焦点
Returns:
void- Inherited From:
-
setFormDataName(name) → {any}
-
Parameters:
Name Type Description name
string Returns:
any- Inherited From:
-
setHeaderBackground(background) → {void}
-
设置正常状态下标题栏背景
Parameters:
Name Type Description background
any 标题栏背景,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setHeaderBackgroundDrawable(drawable) → {void}
-
设置正常状态下标题栏背景的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 标题栏背景
Returns:
void- Inherited From:
-
setHeaderHeight(height) → {void}
-
设置标题栏高度
Parameters:
Name Type Description height
number 标题栏高度
Returns:
void- Inherited From:
-
setHeaderPaddingLeft(paddingLeft) → {void}
-
设置标题栏左侧内边距
Parameters:
Name Type Description paddingLeft
number 左侧内边距
Returns:
void- Inherited From:
-
setHeaderPaddingRight(paddingRight) → {void}
-
设置标题栏右侧内边距
Parameters:
Name Type Description paddingRight
number 右侧内边距
Returns:
void- Inherited From:
-
setHeaderState(state) → {void}
-
设置标题栏状态
Parameters:
Name Type Description state
string 标题栏状态,可选值为:'normal'|'hover'|'active'
Returns:
void- Inherited From:
-
setHeaderVisible(visible) → {void}
-
设置标题栏是否可见
Parameters:
Name Type Description visible
boolean 是否可见
Returns:
void- Inherited From:
-
setHeight(height) → {void}
-
设置组件的高度
Parameters:
Name Type Description height
number 组件高度
Returns:
void- Inherited From:
-
setHoverCollapseIcon(icon) → {void}
-
设置 Hover 状态下合并图标
Parameters:
Name Type Description icon
any 合并图标,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setHoverCollapseIconDrawable(drawable) → {void}
-
设置 Hover 状态下合并图标的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 合并图标
Returns:
void- Inherited From:
-
setHoverExpandIcon(icon) → {void}
-
设置 Hover 状态下展开图标
Parameters:
Name Type Description icon
any 展开图标,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setHoverExpandIconDrawable(drawable) → {void}
-
设置 Hover 状态下展开图标的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 展开图标
Returns:
void- Inherited From:
-
setHoverHeaderBackground(background) → {void}
-
设置 Hover 状态下标题栏背景
Parameters:
Name Type Description background
any 标题栏背景,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setHoverHeaderBackgroundDrawable(drawable) → {void}
-
设置 Hover 状态下标题栏背景的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 标题栏背景
Returns:
void- Inherited From:
-
setHoverTitleColor(color) → {void}
-
设置 Hover 状态下标题文本颜色
Parameters:
Name Type Description color
string 颜色值
Returns:
void- Inherited From:
-
setIcon(icon) → {void}
-
设置标题栏图标
Parameters:
Name Type Description icon
any 图标,可以是颜色或者图片等
Returns:
void- Inherited From:
-
setIconDrawable(drawable) → {void}
-
设置标题栏图标的 Drawable 对象
Parameters:
Name Type Description drawable
ht.ui.drawable.Drawable 图标
Returns:
void- Inherited From:
-
setIconHeight(height) → {void}
-
设置标题栏图标高度
Parameters:
Name Type Description height
number 图标高度
Returns:
void- Inherited From:
-
setIconTitleGap(gap) → {void}
-
设置标题栏图文字和图标之间的距离
Parameters:
Name Type Description gap
number 间距值
Returns:
void- Inherited From:
-
setIconWidth(width) → {void}
-
设置标题栏图标宽度
Parameters:
Name Type Description width
number 图标宽度
Returns:
void- Inherited From:
-
setId(id) → {void}
-
设置唯一标识,根据标识可快速查找到组件
Parameters:
Name Type Description id
string | number 唯一标识
Returns:
void- Inherited From:
-
setLayoutParams(layoutParams, value) → {void}
-
设置布局参数;这个函数有两种使用方式:
view.setLayoutParams({ marginLeft: 20, marginRight: 20 }) 指定布局参数对象
view.setLayoutParams('marginLeft', 20) 传入两个参数设置布局参数对象中的属性Parameters:
Name Type Attributes Description layoutParams
any <optional>
布局参数对象或 key
value
any <optional>
布局参数值
Returns:
void- Inherited From:
-
setLoading(arg0) → {void}
-
Parameters:
Name Type Description arg0
boolean Returns:
void- Inherited From:
-
setMargin(margin) → {void}
-
设置组件外边距,如果是数字,说明四边使用相同的外边距;如果是数组,则格式为:[上边距, 右边距, 下边距, 左边距]
Parameters:
Name Type Description margin
number | Array.<number> 外边距;父容器布局时,会动态将此参数填充到 layoutParams 中(优先级低于 layoutParams,如果 layoutParams 参数中没有指定相应的 margin 才会从组件上取值)
Returns:
void- Inherited From:
-
setMaxSize(width, height) → {void}
-
Parameters:
Name Type Attributes Description width
number <optional>
height
number <optional>
Returns:
void- Inherited From:
-
setMemoryValidate(validate) → {void}
-
Parameters:
Name Type Description validate
boolean Returns:
void- Inherited From:
-
setMinSize(width, height) → {void}
-
Parameters:
Name Type Attributes Description width
number <optional>
height
number <optional>
Returns:
void- Inherited From:
-
setOverflow(value) → {void}
-
Parameters:
Name Type Description value
"auto" | "clip" | "hidden" | "visible" | "scroll" Returns:
void- Inherited From:
-
setPadding(padding) → {void}
-
设置组件内边距,如果是数字,说明四边使用相同的内边距;如果是数组,则格式为:[上边距, 右边距, 下边距, 左边距]
Parameters:
Name Type Description padding
number | Array.<Number> 内边距
Returns:
void- Inherited From:
-
setPopover(popover, trigger) → {void}
-
设置弹框组件
Parameters:
Name Type Attributes Description popover
string | ht.ui.Popover 弹框组件,如果参数是字符串,则用这段文本作为弹框内容(内部自动创建 Popover 和 HtmlView 组件)
trigger
string <optional>
触发器,值为:click|hover
Returns:
void- Inherited From:
-
setPopoverPlacements(placements) → {void}
-
设置弹框组件的弹出位置
Parameters:
Name Type Description placements
Array.<string> 位置数组
Returns:
void- Inherited From:
-
setPopoverTrigger(trigger) → {void}
-
设置弹框触发器
Parameters:
Name Type Description trigger
string 弹框触发器,值为:click|hover
Returns:
void- Inherited From:
-
setPreferredSize(width, height) → {void}
-
设置 preferredSize,preferredSize 表示组件自身最合适的尺寸,布局器布局时会考虑此尺寸作为布局尺寸;
如果设置过 preferredSize,就不会再调用 figurePreferredSize 计算;
如果要清空设置过的 preferredSize,可以调用 setPreferredSize(undefined, undefined);Parameters:
Name Type Attributes Description width
number | Size2d <optional>
首选宽度
height
number <optional>
首选高度
Returns:
void- Inherited From:
-
setPropertyValue(name, value) → {void}
-
设置属性值并派发事件,自定义 set 函数内部应该调用此函数设值
Parameters:
Name Type Description name
string 属性名
value
any 属性值
Returns:
void- Inherited From:
-
setRedrawOnFocus(redrawOnFocus) → {void}
-
设置组件获取或失去焦点时,是否重绘自身
Parameters:
Name Type Description redrawOnFocus
boolean 是否重绘自身
Returns:
void- Inherited From:
-
setScrollBarActiveSize(activeSize) → {void}
-
设置滚动条感应区域的大小
Parameters:
Name Type Description activeSize
number 滚动条感应区域的大小
Returns:
void- Inherited From:
-
setScrollBarColor(color) → {void}
-
设置滚动条颜色
Parameters:
Name Type Description color
string 颜色值
Returns:
void- Inherited From:
-
setScrollBarMinLength(length) → {void}
-
设置滚动条最小长度
Parameters:
Name Type Description length
number 滚动条最小长度
Returns:
void- Inherited From:
-
setScrollBarMode(mode) → {void}
-
设置滚动条模式
Parameters:
Name Type Description mode
string 滚动条模式,可选值为:'on'|'off'|'auto'|'hidden'
Returns:
void- Inherited From:
-
setScrollBarSize(size) → {void}
-
设置滚动条大小(横向滚动条的高度,纵向滚动条的宽度)
Parameters:
Name Type Description size
number 滚动条大小
Returns:
void- Inherited From:
-
setScrollBarTimeout(timeout) → {void}
-
设置滚动条显示时间,超过时间后滚动条将隐藏
Parameters:
Name Type Description timeout
number 滚动条显示时间
Returns:
void- Inherited From:
-
setStyle(property, value) → {void}
-
Parameters:
Name Type Description property
string value
any Returns:
void- Inherited From:
-
setTitle(title) → {void}
-
设置标题文本
Parameters:
Name Type Description title
string 标题文本
Returns:
void- Inherited From:
-
setTitleColor(color) → {void}
-
设置正常状态下标题文本颜色
Parameters:
Name Type Description color
string 颜色值
Returns:
void- Inherited From:
-
setTitleFont(font) → {void}
-
设置标题文本字体
Parameters:
Name Type Description font
string 标题文本字体,如 '12px Arial'
Returns:
void- Inherited From:
-
setToolGap(gap) → {void}
-
设置标题栏工具按钮之间的距离
Parameters:
Name Type Description gap
number 间距值
Returns:
void- Inherited From:
-
setToolHeight(height) → {void}
-
设置标题栏工具按钮高度
Parameters:
Name Type Description height
number 高度值
Returns:
void- Inherited From:
-
setTools(tools) → {void}
-
设置标题栏的工具按钮
Parameters:
Name Type Description tools
Array.<any> Returns:
void- Inherited From:
Example
panel.setTools([{ icon: 'roundNormal', hoverIcon: 'roundHover', activeIcon: 'roundActive', onClick: function(event) { console.log('click tool', event); } }]);
-
setToolsPosition(position) → {void}
-
设置标题栏工具按钮的位置
Parameters:
Name Type Description position
string 工具按钮位置,值为:left|right
Returns:
void- Inherited From:
-
setToolTipEnabled(enabled) → {void}
-
设置是否启用工具提示
Parameters:
Name Type Description enabled
boolean 是否启用工具提示
Returns:
void- Inherited From:
-
setToolTipPlacements(placements) → {any}
-
Parameters:
Name Type Description placements
Array.<string> Returns:
any- Inherited From:
-
setToolWidth(width) → {void}
-
设置标题栏工具按钮宽度
Parameters:
Name Type Description width
number 宽度值
Returns:
void- Inherited From:
-
setTranslate(translateX, translateY, anim) → {void}
-
设置水平和垂直滚动值
Parameters:
Name Type Attributes Description translateX
number 水平滚动值
translateY
number <optional>
垂直滚动值
anim
boolean <optional>
是否使用动画
Returns:
void- Inherited From:
-
setTranslateX(translateX) → {void}
-
设置水平滚动值
Parameters:
Name Type Description translateX
number 水平滚动值
Returns:
void- Inherited From:
-
setTranslateY(translateY) → {void}
-
设置垂直滚动值
Parameters:
Name Type Description translateY
number 垂直滚动值
Returns:
void- Inherited From:
-
setVisible(visible) → {void}
-
设置组件是否可见
Parameters:
Name Type Description visible
boolean 组件是否可见
Returns:
void- Inherited From:
-
setWidth(width) → {void}
-
设置组件的宽度
Parameters:
Name Type Description width
number 组件宽度
Returns:
void- Inherited From:
-
setX(x) → {void}
-
设置组件的 x 坐标
Parameters:
Name Type Description x
number x 坐标
Returns:
void- Inherited From:
-
setY(y) → {void}
-
设置组件的 y 坐标
Parameters:
Name Type Description y
number y 坐标
Returns:
void- Inherited From:
-
setZIndex(zIndex) → {void}
-
设置组件的堆叠顺序
Parameters:
Name Type Description zIndex
number 堆叠顺序
Returns:
void- Inherited From:
-
setZoom(zoom) → {void}
-
设置缩放
Parameters:
Name Type Description zoom
number 缩放值
Returns:
void- Inherited From:
-
setZoomAnchor(anchor) → {void}
-
设置缩放锚点
Parameters:
Name Type Description anchor
Array.<number> 横向和纵向锚点数组,如右上角为:[1, 0]
Returns:
void- Inherited From:
-
showHScrollBar() → {void}
-
显示水平滚动条
Returns:
void- Inherited From:
-
showPopover() → {void}
-
显示弹框组件
Returns:
void- Inherited From:
-
showScrollBar() → {void}
-
显示滚动条,内部会调用 showVScrollBar() 和 showHScrollBar()
Returns:
void- Inherited From:
-
showToolTip(moveEvent) → {void}
-
显示 toolTip
Parameters:
Name Type Description moveEvent
MouseEvent | TouchEvent 鼠标事件对象
Returns:
void- Inherited From:
-
showVScrollBar() → {void}
-
显示垂直滚动条
Returns:
void- Inherited From:
-
tearDownBorder(border, x, y, width, height, dom) → {void}
-
卸载边框;只有 CSS 类型的边框才需要此函数
Parameters:
Name Type Attributes Description border
ht.ui.border.Border <optional>
边框对象
x
number <optional>
起点 x 坐标
y
number <optional>
起点 y 坐标
width
number <optional>
宽度
height
number <optional>
高度
dom
HTMLElement <optional>
指定绘制的目标 DOM
Returns:
void- Inherited From:
-
translate(x, y, anim) → {void}
-
水平滚动值增加 x,垂直滚动值增加 y
Parameters:
Name Type Attributes Description x
number 水平滚动值增量
y
number <optional>
垂直滚动值增量
anim
boolean <optional>
是否使用动画
Returns:
void- Inherited From:
-
tx(value) → {number|void}
-
获取或设置水平滚动值
Parameters:
Name Type Attributes Description value
number <optional>
如果为空,相当于 getTranslateX();如果不为空,相当于 setTranslateX(value)
Returns:
number | void- Inherited From:
-
ty(value) → {number|void}
-
获取或设置垂直滚动值
Parameters:
Name Type Attributes Description value
number <optional>
如果为空,相当于 getTranslateY();如果不为空,相当于 setTranslateY(value)
Returns:
number | void- Inherited From:
-
ump(listener, scope) → {void}
-
删除属性事件变化监听器,removePropertyChangeListener 的缩写
Parameters:
Name Type Attributes Description listener
Object 监听器函数
scope
any <optional>
函数域
Returns:
void- Inherited From:
-
updateScrollBar(width, height, scrollWidth, scrollHeight) → {void}
-
更新滚动条;如果布局器需要滚动条,应该在 validateImpl 函数的末尾调用此函数更新滚动条
Parameters:
Name Type Description width
number 组件布局宽度
height
number 组件布局高度
scrollWidth
number 组件内容宽度
scrollHeight
number 组件内容高度
Returns:
void- Inherited From:
-
validate() → {void}
-
重绘组件;此函数负责重新布局组件 DOM、设置层叠关系、加载需要的图片资源、派发 validate 事件等
如果自定义组件,不要重写此函数,而是重写 validateImpl 函数Returns:
void- Inherited From:
-
validateImpl(x, y, width, height) → {void}
-
绘制组件内容;如果自定义组件,一般要重写此函数,通过 getRootContext() 获取画笔然后绘制
Parameters:
Name Type Attributes Description x
number <optional>
内容范围的 x 坐标
y
number <optional>
内容范围的 y 坐标
width
number <optional>
内容范围宽度
height
number <optional>
内容范围高度
Returns:
void- Inherited From: