ngui/event
Enum: HighlightedStatus
View.onHighlighted
事件數(shù)據(jù)的狀態(tài)枚舉類型
Enum: ReturnValueMask
GUI事件數(shù)據(jù)返回值掩碼,如果返回值被設(shè)置成0
,表示同時取消默認(rèn)動作與事件冒泡
鍵盤按鍵對應(yīng)的按鍵代碼
Object: GUITouch
觸摸事件返回的數(shù)據(jù)結(jié)構(gòu), 這是個Object
類型描述并沒有實(shí)際存在的構(gòu)造函數(shù)
uint
}float
}float
}float
}float
}float
}View
}Class: Notification
這是事件EventNoticer
的集合,事件觸發(fā)與響應(yīng)中心
繼承于它的派生類型可以使用event
關(guān)鍵字來聲明成員事件
通過事件名稱觸發(fā)事件 --> EventNoticer.trigger(data)
通過名稱與Event
觸發(fā)事件 --> EventNoticer.triggerWithEvent(event)
獲取notification
上的所有EventNoticer
notification
{Notification
}Array
} 返回內(nèi)容為EventNoticer
的Array
卸載notification
上所有與scope
相關(guān)的偵聽器
實(shí)際上遍歷調(diào)用了EventNoticer.off(scope)
方法
notification
{Notification
}scope
{Object
}Example:
class TestNotification extends Notification {
eventonChange; // 這里必須以on開始以;分號結(jié)束
}
var notification = new TestNotification();
// Prints: responseonChange 0 100
notification.onChange = function(ev) { // add default listener
console.log('responseonChange 0', ev.data)
}
notification.triggerChange(100);
// Prints:
// responseonChange 0 200
// responseonChange 1
notification.onChange.on(function(ev) {
console.log('responseonChange 1')
})
notification.triggerWithEvent('change', new Event(200));
var noticer = notification.onChange;
noticer.off(0) // delete default listener
// Prints: responseonChange 1
notification.triggerChange();
Class: EventNoticer
事件通知者,事件監(jiān)聽器添加與刪除、觸發(fā)與通知都由它實(shí)現(xiàn)
事件是否啟用,noticer.enable=false
可禁用事件的發(fā)送,Default true
bool
}事件的名稱
String
}
返回初始化時的sender
對像
Object
}監(jiān)聽器數(shù)量
uint
}
添加監(jiān)聽器函數(shù),并指定scopethis
func
{Function
} 監(jiān)聽器函數(shù)[scope]
{Object
} 范圍this
對像[id]
{int
} 指定一個id
,如果不指定自動生成一個,如果指定的id
已經(jīng)存在會替換之前的監(jiān)聽器int
} return id
返回傳入的id
或自動生成的id
Example:
var scope = { a:100 }
var id = display_port.onChange.on(function(ev) {
// Prints: 100
console.log(this.a)
}, scope)
// 替換監(jiān)聽器
display_port.onChange.on(function(ev) {
// Prints: replace 100
console.log('replace', this.a)
}, scope, id)
添加監(jiān)聽器函數(shù),并指定scopethis
,只監(jiān)聽一次
添加監(jiān)聽器函數(shù),并指定scopethis
,與on()
僅回調(diào)參數(shù)不相同
Example:
var scope = { a:100 }
var id = display_port.onChange.on2(function(scope, ev) {
// Prints: 100
console.log(scope.a)
}, scope)
添加監(jiān)聽器函數(shù),并指定scopethis
,只監(jiān)聽一次
觸發(fā)事件數(shù)據(jù),并發(fā)送數(shù)據(jù)
[data]
{Object
}int
} return Event.returnValue
通過Event
觸發(fā)事件
event
{Event
}int
} return Event.returnValue
刪除所有監(jiān)聽器
通過id
刪除監(jiān)聽器
id
{int
}
通過scope
刪除一個監(jiān)聽器
scope
{Object
}
通過listen
函數(shù)與scope
刪除一個監(jiān)聽器
Class: Event
事件數(shù)據(jù)上下文
[data]
{Object
}String
}Object
}Object
}int
}Class: GUIEvent
extends
Event
GUI事件數(shù)據(jù)上下文,構(gòu)造函數(shù)為私有不能訪問
View
}uint64
}取消默認(rèn)動作
returnValue &= ~RETURN_VALUE_MASK_DEFAULT
取消事件冒泡
returnValue &= ~RETURN_VALUE_MASK_BUBBLE
returnValue & RETURN_VALUE_MASK_DEFAULT
bool
}
returnValue & RETURN_VALUE_MASK_BUBBLE
bool
}Class: GUIActionEvent
extends
{GUIEvent
}Action
}uint64
}uint
}uint
}Class: GUIKeyEvent
extends
{GUIEvent
}int
}bool
}bool
}bool
}bool
}bool
}int
}int
}View
}Class: GUIClickEvent
extends
{GUIEvent
}float
}float
}uint
}bool
}Class: GUIHighlightedEvent
extends
{GUIEvent
}Class: GUITouchEvent
extends
{GUIEvent
}Class: GUIFocusMoveEvent
extends
{GUIEvent
}變化前的焦點(diǎn)視圖
View
}變化后的焦點(diǎn)視圖
View
}
更多建議: