本文整理汇总了C++中EventTarget::AddListener方法的典型用法代码示例。如果您正苦于以下问题:C++ EventTarget::AddListener方法的具体用法?C++ EventTarget::AddListener怎么用?C++ EventTarget::AddListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventTarget
的用法示例。
在下文中一共展示了EventTarget::AddListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _
/*!
\brief Adds the specified listener or updates its event mask and options
if already added.
It follows the BView semantics in that specifiying an event mask of zero
leaves the event mask untouched and just updates the options.
*/
bool
EventDispatcher::_AddListener(EventTarget& target, int32 token,
uint32 eventMask, uint32 options, bool temporary)
{
BAutolock _(this);
if (temporary && fLastButtons == 0) {
// only allow to add temporary listeners in case a buttons is pressed
return false;
}
if (!fTargets.HasItem(&target))
fTargets.AddItem(&target);
event_listener* listener = target.FindListener(token);
if (listener != NULL) {
// we already have this target, update its event mask
if (temporary) {
if (eventMask != 0)
listener->temporary_event_mask = eventMask;
listener->temporary_options = options;
} else {
if (eventMask != 0)
listener->event_mask = eventMask;
listener->options = options;
}
return true;
}
if (eventMask == 0)
return false;
ETRACE(("events: add listener: token %ld, eventMask = %ld, options = %ld, %s\n",
token, eventMask, options, temporary ? "temporary" : "permanent"));
// we need a new target
bool success = target.AddListener(token, eventMask, options, temporary);
if (!success) {
if (target.IsEmpty())
fTargets.RemoveItem(&target);
} else {
if (options & B_SUSPEND_VIEW_FOCUS)
fSuspendFocus = true;
}
return success;
}