eui.UIEvent
包 eui
类 public class UIEvent
继承 eui.UIEvent → egret.Event → egret.HashObject
UI事件
公共属性
属性 |
---|
CHANGE_END : string [静态]改变结束 |
CHANGE_START : string [静态]改变开始 |
CLOSING : string [静态]即将关闭面板事件 |
CREATION_COMPLETE : string [静态]组件创建完成 |
MOVE : string [静态]UI组件在父级容器中的坐标发生改变事件 |
公共方法
方法 |
---|
UIEvent(type:string,bubbles:boolean,cancelable:boolean) 创建一个 UIEvent 实例 |
dispatchUIEvent(target:egret.IEventDispatcher,eventType:string,bubbles:boolean,cancelable:boolean):boolean [静态]使用指定的EventDispatcher对象来抛出事件对象 |
属性详细信息
CHANGE_END
CHANGE_END : string = "changeEnd"
- 支持版本:eui 1.0
- 运行平台:Web,Native
改变结束
CHANGE_START
CHANGE_START : string = "changeStart"
- 支持版本:eui 1.0
- 运行平台:Web,Native
改变开始
CLOSING
CLOSING : string = "closing"
- 支持版本:eui 1.0
- 运行平台:Web,Native
即将关闭面板事件
CREATION_COMPLETE
CREATION_COMPLETE : string = "creationComplete"
- 支持版本:eui 1.0
- 运行平台:Web,Native
组件创建完成
MOVE
MOVE : string = "move"
- 支持版本:eui 1.0
- 运行平台:Web,Native
UI组件在父级容器中的坐标发生改变事件
方法详细信息
UIEvent()
public UIEvent(type:string,bubbles:boolean,cancelable:boolean)
创建一个 UIEvent 实例
- 支持版本:eui 1.0
- 运行平台:Web,Native
- 参数
dispatchUIEvent()
public dispatchUIEvent(target:egret.IEventDispatcher,eventType:string,bubbles:boolean,cancelable:boolean):boolean
使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。
- 支持版本:eui 1.0
- 运行平台:Web,Native
- 参数
- target:egret.IEventDispatcher - 事件派发目标。
- eventType:string - 事件类型;指示触发事件的动作。
- bubbles:boolean - 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
- cancelable:boolean - 确定是否可以取消 Event 对象。默认值为 false。
示例
**
* 以下示例使用 UIEventExample 类来演示UI组件触发事件
*/
class UIEventExample extends egret.Sprite {
constructor() {
super();
this.once(egret.Event.ADDED_TO_STAGE, this.init, this);
}
private progress: eui.ProgressBar;
private init(): void {
var panel = this.getPanel();
panel.x = 200;
panel.addEventListener(eui.UIEvent.CREATION_COMPLETE, this.onUIEventHandler, this);
panel.addEventListener(eui.UIEvent.CLOSING, this.onUIEventHandler, this);
panel.addEventListener(eui.UIEvent.MOVE, this.onUIEventHandler, this);
this.addChild(panel);
var list = new eui.List();
var arr = new eui.ArrayCollection([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
list.dataProvider = arr;
list.itemRenderer = IR_UIEvents;
var scroller = new eui.Scroller();
scroller.viewport = list;
scroller.height = 190;
this.addChild(scroller);
scroller.addEventListener(eui.UIEvent.CHANGE_START, this.onUIEventHandler, this);
scroller.addEventListener(egret.Event.CHANGE, this.onChangeHander, this);
scroller.addEventListener(eui.UIEvent.CHANGE_END, this.onUIEventHandler, this);
}
private onUIEventHandler(e: eui.UIEvent): void {
egret.log("eui.UIEvent:",e.type);
}
private onChangeHander(e: egret.Event): void {
egret.log("egret.Event:",e.type);
}
private getPanel(): eui.Panel {
var exmlButton =
`<e:Skin class="skins.ButtonSkin" states="up,down,disabled" minHeight="50" minWidth="100" xmlns:e="http:/ns.egret.com/eui">
<e:Image source="resource/button_up.png" source.down="resource/button_down.png" scale9Grid="1,3,8,8" width="100%" height="100%"/>
<e:Label id="labelDisplay" top="8" bottom="8" left="8" right="8" size="20" fontFamily="Tahoma" textColor="0xFFFFFF" verticalAlign="middle" textAlign="center"/>
</e:Skin>`;
EXML.parse(exmlButton);
var exml =
`<e:Skin class="skins.PanelSkin" xmlns:e="http:/ns.egret.com/eui" minWidth="450" minHeight="25">
<e:Image left="0" right="0" bottom="0" top="0" source="resource/border.png" scale9Grid="2,2,12,12"/>
<e:Group id="moveArea" left="0" right="0" top="1" height="45">
<e:Image left="0" right="0" bottom="0" top="0" source="resource/header.png"/>
<e:Label id="titleDisplay" size="20" fontFamily="Tahoma" textColor="0xFFFFFF" wordWrap="false" left="15" right="5" verticalCenter="0"/>
</e:Group>
<e:Group id="contentGroup" width="100%" height="200" top="50" bottom="30"/>
<e:Button skinName = "skins.ButtonSkin" id="closeButton" label="close" bottom="5" horizontalCenter="0"/>
</e:Skin>`;
var clazz = EXML.parse(exml);
var panel = new eui.Panel();
panel.skinName = "skins.PanelSkin";
return panel;
}
}
class IR_UIEvents extends eui.ItemRenderer {
private label: eui.Label;
constructor() {
super();
this.label = new eui.Label();
this.addChild(this.label);
}
protected dataChanged(): void {
this.label.text = "label:" + this.data.toString();
}
}