ht.widget.Button()

new Button()

创建按钮组件

Requires:
  • module:ht-form.js

Requires

  • module:ht-form.js

Methods

addPropertyChangeListener(listener, scope, ahead) → {void}

增加自身属性变化事件监听器

Parameters:
Name Type Attributes Description
listener function

监听器函数

scope Object <optional>

监听器函数域

ahead boolean <optional>

是否将当前监听器插入到监听器列表开头

Returns:
void
See:

addToDOM(parentNode) → {void}

将组件加入到指定的 DOM 元素底下,不指定则加入到 document.body 下

Parameters:
Name Type Attributes Description
parentNode HTMLElement <optional>

父 DOM,默认为 document.body

Returns:
void

addViewListener(listener, scope, ahead) → {void}

监听视图事件,如布局、刷新等

Parameters:
Name Type Attributes Description
listener function

监听器函数

scope Object <optional>

监听器函数域

ahead boolean <optional>

是否将当前监听器插入到监听器列表开头

Returns:
void

disableToolTip() → {void}

关闭ToolTip功能

Returns:
void

enableToolTip() → {void}

启用ToolTip

Returns:
void

firePropertyChange(property, oldValue, newValue, equalFunc, params) → {void}

派发属性变化事件

Parameters:
Name Type Attributes Description
property string

属性

oldValue any

旧值

newValue any

新值

equalFunc function <optional>

相等判断函数

params any <optional>

其它参数

Returns:
void
See:

fireViewEvent(kind) → {void}

Parameters:
Name Type Description
kind string
Returns:
void

fp(property, oldValue, newValue, equalFunc, params) → {void}

派发属性变化事件,firePropertyChange 方法的简写

Parameters:
Name Type Attributes Description
property string

属性

oldValue any

旧值

newValue any

新值

equalFunc function <optional>

相等判断函数

params any <optional>

其它参数

Returns:
void
See:

getBackground() → {string}

获取按钮背景颜色

Returns:
string -

按钮背景颜色

getBorderColor() → {string}

获取按钮边框色

Returns:
string -

颜色值

getClass() → {function}

获取类声明(构造函数)

Returns:
function -

类声明(构造函数)

getClassName() → {string}

获取类全名

Returns:
string -

类全名

getCurrentBackground() → {string}

获取按钮当前背景颜色

Returns:
string -

颜色值

getCurrentBorderColor() → {string}

获取按钮当前边框颜色

Returns:
string -

颜色值

getDisabledDiv() → {HTMLElement}

获取被禁用组件的div

Returns:
HTMLElement -

被禁用组件的div

getGroupId() → {string}

获取组编号

Returns:
string -

groupId

getHeight() → {number}

获取布局高度

Returns:
number -

布局高度

getIcon() → {string}

获取图标

Returns:
string -

icon

getIconColor() → {string}

获取图标颜色

Returns:
string -

图标颜色

getLabel() → {string}

获取文本

Returns:
string -

文本

getLabelColor() → {string}

获取文本颜色

Returns:
string -

文本颜色

getLabelFont() → {string}

获取文本字体

Returns:
string -

文本字体

getLabelSelectColor() → {string}

获取选择文本颜色

Returns:
string -

选择文本颜色

getOrientation() → {string}

获取布局方式,v 上下布局,h 左右布局

Returns:
string -

布局方式

getSelectBackground() → {string}

获取选中背景色

Returns:
string -

选中背景色

getSuperClass() → {function}

获取父类声明(构造函数)

Returns:
function -

父类声明(构造函数)

getToolTip() → {string}

获取ToolTip文字,可重载返回自定义的toolTip文字

Returns:
string -

toolTip文字

getValue() → {string}

按钮元素值

Returns:
string -

按钮元素值

See:
  • RadioButton#v v

getView() → {HTMLElement}

获取组件的根层div

Returns:
HTMLElement -

组件的根层div

getWidth() → {number}

获取布局宽度

Returns:
number -

布局宽度

invalidate(delay) → {void}

无效组件,并调用延时刷新

Parameters:
Name Type Description
delay number

延迟刷新的间隔事件(单位:ms)

Returns:
void
See:

isClickable() → {boolean}

获取按钮是否可点击

Returns:
boolean

isDisabled() → {boolean}

获取组件是否可用

Returns:
boolean

isPressed() → {boolean}

获取按钮处于可按状态

Returns:
boolean

isSelected() → {boolean}

获取按钮选择状态

Returns:
boolean

isTogglable() → {boolean}

获取按钮是否打开开关

Returns:
boolean

isToolTipEnabled() → {boolean}

获取提示功能是否可用

Returns:
boolean

iv(delay) → {void}

无效组件,并调用延时刷新

Parameters:
Name Type Description
delay number

延迟刷新的间隔事件(单位:ms)

Returns:
void
See:

layout(x, y, width, height) → {void}

执行布局

Parameters:
Name Type Description
x number

视图左上角布局 x 点位置

y number

视图左上角布局 y 点位置

width number

视图宽度

height number

视图高度

Returns:
void

mp(listener, scope, ahead) → {void}

增加自身属性变化事件监听器的缩写

Parameters:
Name Type Attributes Description
listener function

监听器函数

scope any <optional>

监听器函数域

ahead boolean <optional>

是否将当前监听器插入到监听器列表开头

Returns:
void
See:

onClicked() → {void}

按钮点击事件,可重载监听

Returns:
void

onPropertyChanged(event) → {void}

属性变化回调函数,可重载做后续处理

Parameters:
Name Type Description
event Object

属性变化事件

Returns:
void
Example
//event格式:
{
	property: 'name',//发生变化的属性
	oldValue: 'oldValue',//旧值
	newValue: 'newValue',''新值
	data: data//发生变化的data
}

onSelectedChanged() → {void}

按钮选择事件,可重载监听

Returns:
void

removePropertyChangeListener(listener, scope) → {void}

删除自身属性变化事件监听器

Parameters:
Name Type Attributes Description
listener function

监听器函数

scope Object <optional>

监听器函数域

Returns:
void

removeViewListener(listener, scope) → {void}

删除视图事件监听器

Parameters:
Name Type Attributes Description
listener function

监听器函数

scope Object <optional>

监听器函数域

Returns:
void

setBackground(color) → {void}

设置按钮背景颜色

Parameters:
Name Type Description
color string

颜色

Returns:
void

setBorderColor(color) → {void}

设置按钮边框颜色

Parameters:
Name Type Description
color string

颜色

Returns:
void

setClickable(v) → {void}

设置按钮是否可点击

Parameters:
Name Type Description
v boolean
Returns:
void

setCursor(style) → {void}

设置 css 的鼠标样式,cursor

Parameters:
Name Type Description
style string

css 的鼠标样式

Returns:
void

setDisabled(value, iconUrl) → {void}

设置组件是否处于不可用状态,处于不可用状态时不能进行任何操作并且会遮挡一层蒙板

Parameters:
Name Type Attributes Description
value boolean

是否禁用组件

iconUrl string <optional>

蒙板上显示的icon的路径

Returns:
void

setFocus(value) → {void}

根据值给组件设置焦点

Parameters:
Name Type Attributes Description
value string <optional>
Returns:
void

setGroupId(groupId) → {void}

设置组编号

Parameters:
Name Type Description
groupId string

组编号

Returns:
void

setHeight(height) → {void}

设置布局高度

Parameters:
Name Type Description
height number

高度值

Returns:
void

setIcon(icon) → {void}

设置按钮图标

Parameters:
Name Type Description
icon string

按钮图标

Returns:
void

setIconColor(color) → {void}

设置按钮图标颜色

Parameters:
Name Type Description
color string

图标颜色

Returns:
void

setLabel(text) → {void}

设置按钮文字

Parameters:
Name Type Description
text string

按钮文字

Returns:
void

setLabelColor(Color) → {void}

设置按钮文字颜色

Parameters:
Name Type Description
Color string

文字颜色

Returns:
void

setLabelFont(font) → {void}

设置按钮文字字体

Parameters:
Name Type Description
font string

字体

Returns:
void

setLabelSelectColor(color) → {void}

设置按钮选中文字颜色

Parameters:
Name Type Description
color string

颜色值

Returns:
void

setOrientation(v) → {void}

设置布局方式,默认为 vertical 或 v,可设置为 horizontal 或 h

Parameters:
Name Type Description
v string

布局方式

Returns:
void

setPressed(value) → {void}

设置按钮是否处于按下状态

Parameters:
Name Type Description
value boolean
Returns:
void

setSelectBackground(color) → {void}

设置按钮选中背景颜色

Parameters:
Name Type Description
color string

颜色值

Returns:
void

setSelected(value) → {void}

设置按钮是否处于选中状态

Parameters:
Name Type Description
value boolean
Returns:
void

setTogglable(value) → {void}

设置按钮是否打开开关

Parameters:
Name Type Description
value boolean
Returns:
void

setToolTip(toolTip) → {void}

设置文字提示信息

Parameters:
Name Type Description
toolTip string

文字提示

Returns:
void

setToolTipEnabled(enable) → {void}

设置提示是否可用

Parameters:
Name Type Description
enable boolean
Returns:
void

setValue(value) → {void}

设置按钮的值

Parameters:
Name Type Description
value string
Returns:
void

setWidth(width) → {void}

设置布局宽度

Parameters:
Name Type Description
width number

宽度值

Returns:
void

ump(listener, scope) → {void}

删除自身属性变化事件监听器,removePropertyChangeListener的缩写

Parameters:
Name Type Attributes Description
listener function

监听器函数

scope Object <optional>

监听器函数域

Returns:
void
See:

validate() → {void}

立刻刷新拓扑

Returns:
void

validateImpl() → {void}

刷新

Returns:
void