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) → {void}

增加按钮

Parameters:
Name Type Description
button ht.ui.ToggleButton

按钮

Returns:
void

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

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

Parameters:
Name Type Attributes Description
listener Object

监听器函数

scope object <optional>

函数域

ahead boolean <optional>

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

Returns:
void

clear() → {void}

清除内部所有的按钮

Returns:
void

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

派发属性变化事件

Parameters:
Name Type Attributes Description
property string

属性名

oldValue any

属性变化之前的值

newValue any

属性变化之后的值

compareFunc Object <optional>

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

Returns:
boolean -

事件是否派发成功

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

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

Parameters:
Name Type Attributes Description
property string

属性名

oldValue any

属性变化之前的值

newValue any

属性变化之后的值

compareFunc Object <optional>

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

Returns:
boolean -

事件是否派发成功

getButtons() → {Array.<ht.ui.ToggleButton>}

获取所有被管理的按钮

Returns:
Array.<ht.ui.ToggleButton> -

按钮数组

getSelectedButton() → {ht.ui.ToggleButton}

获取选中的按钮

Returns:
ht.ui.ToggleButton -

选中的按钮

isEmptiable() → {boolean}

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

Returns:
boolean

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

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

Parameters:
Name Type Attributes Description
listener Object

监听器函数

scope object <optional>

函数域

ahead boolean <optional>

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

Returns:
void

remove(button) → {void}

移除按钮

Parameters:
Name Type Description
button ht.ui.ToggleButton

按钮

Returns:
void

removePropertyChangeListener(listener, scope) → {void}

删除属性事件变化监听器

Parameters:
Name Type Attributes Description
listener Object

监听器函数

scope object <optional>

函数域

Returns:
void

setEmptiable(emptiable) → {void}

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

Parameters:
Name Type Description
emptiable boolean

是否可置空

Returns:
void

ump(listener, scope) → {void}

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

Parameters:
Name Type Attributes Description
listener Object

监听器函数

scope object <optional>

函数域

Returns:
void