eui 按鈕、單選框、復(fù)選框 用法學(xué)習(xí)
//按鈕
let button = new eui.Button();
button.width = 100;
button.height = 40;
button.label = "confirm";
//水平劇中垂直劇中
button.horizontalCenter = 0;
button.verticalCenter = 0;
//button.enabled = false;
// button.skinName = "resource/eui_skins/ButtonSkin.exml";
this.addChild(button);
let button2 = new eui.Button();
button2.width = 200;
button2.height = 100;
button2.label = "c2";
this.addChild(button2);
button.addEventListener(egret.TouchEvent.TOUCH_TAP,this.btnTouchHandler,this);
//egret create Hello helloEUI --type eui
//復(fù)選框
let cbx = new eui.CheckBox();
cbx.label = "Select 1";
cbx.y = 200;
this.addChild(cbx);
cbx.addEventListener(eui.UIEvent.CHANGE,(evt:eui.UIEvent) => {console.log(evt.target.selected);},this)
//單選框-可以遍歷來獲取選中的value
//RadioButtonGroup-用組來獲取選中的value(需要注意的是添加group是rdb.group = radioGroup)
let radioGroup: eui.RadioButtonGroup = new eui.RadioButtonGroup();
radioGroup.addEventListener(eui.UIEvent.CHANGE,(evt:eui.UIEvent) => {egret.log(evt.target.selectedValue);},this);
let rdb: eui.RadioButton = new eui.RadioButton();
rdb.label = "Select 1";
rdb.value = 1;
//plan2
rdb.group = radioGroup;
//plan1(用的是rdb.groupName = "...")
//rdb.groupName = "g1";
this.addChild(rdb);
//rdb.addEventListener(eui.UIEvent.CHANGE,(evt:eui.UIEvent) => {egret.log(evt.target.value);},this);
let rdb2: eui.RadioButton = new eui.RadioButton();
rdb2.label = "Select 2";
rdb2.value = 2;
rdb2.group = radioGroup;
//rdb2.groupName = "g1";
rdb2.y = 100;
this.addChild(rdb2);
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。