Class: Radios

ht.ui. Radios

new Radios()

此类用于配合单选按钮实现选中互斥功能

Example
var radioButton1, radioButton2, radioButton3;

// init radioButton1, radioButton2, radioButton3

var radios = new ht.ui.Radios();
radios.add(radioButton1);
radios.add(radioButton2);
radios.add(radioButton3);
radios.addPropertyChangeListener(function(e) {
		if (e.property === 'selectedButton') {
  		console.log(radios.getSelectedButton());
		}
});

Methods

add(button)

增加按钮

Parameters:
Name Type Description
button ht.ui.ToggleButton

按钮

addPropertyChangeListener(listener, scope, ahead)

增加属性事件变化监听函数

Parameters:
Name Type Argument Description
listener function

监听器函数

scope Object <optional>

函数域

ahead Boolean <optional>

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

clear()

清除内部所有的按钮

firePropertyChange(property, oldValue, newValue, compareFunc) → {Boolean}

派发属性变化事件

Parameters:
Name Type Argument Description
property String

属性名

oldValue Object

属性变化之前的值

newValue Object

属性变化之后的值

compareFunc function <optional>

比较函数,用于比较新值和旧值是否一致,如果一致则不会派发事件

Returns:

事件是否派发成功

Type
Boolean

fp(property, oldValue, newValue, compareFunc) → {Boolean}

派发属性变化事件,firePropertyChange 的缩写

Parameters:
Name Type Argument Description
property String

属性名

oldValue Object

属性变化之前的值

newValue Object

属性变化之后的值

compareFunc function <optional>

比较函数,用于比较新值和旧值是否一致,如果一致则不会派发事件

Returns:

事件是否派发成功

Type
Boolean

getButtons() → {Array}

获取所有被管理的按钮

Returns:

按钮数组

Type
Array

getSelectedButton() → {ht.ui.ToggleButton}

获取选中的按钮

Returns:

选中的按钮

Type
ht.ui.ToggleButton

isEmptiable() → {Boolean}

单选框是否可置空;如果为 false,表示必须选中一个单选框

Returns:
Type
Boolean

mp(listener, scope, ahead)

增加属性事件变化监听函数,addPropertyChangeListener 的缩写

Parameters:
Name Type Argument Description
listener function

监听器函数

scope Object <optional>

函数域

ahead Boolean <optional>

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

remove(button)

移除按钮

Parameters:
Name Type Description
button ht.ui.ToggleButton

按钮

removePropertyChangeListener(listener, scope)

删除属性事件变化监听器

Parameters:
Name Type Argument Description
listener function

监听器函数

scope Object <optional>

函数域

setEmptiable(emptiable)

设置单选框是否可置空;如果为 false,表示必须选中一个单选框

Parameters:
Name Type Description
emptiable Boolean

是否可置空

ump(listener, scope)

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

Parameters:
Name Type Argument Description
listener function

监听器函数

scope Object <optional>

函数域

© 2017 Hightopo Inc. All rights reserved. - Email: service@hightopo.com