[dispatcher] Adding argument for whether to sort listeners when dispatching events.

This commit is contained in:
James Chen 2013-09-15 18:25:44 +08:00
parent 62a0dc41c3
commit bfdc2a0efe
2 changed files with 4 additions and 3 deletions

View File

@ -217,12 +217,13 @@ void EventDispatcher::setPriorityWithFixedValue(EventListener* listener, int fix
} }
} }
void EventDispatcher::dispatchEvent(Event* event) void EventDispatcher::dispatchEvent(Event* event, bool toSortListeners)
{ {
if (_listeners == nullptr || !_isEnabled) if (_listeners == nullptr || !_isEnabled)
return; return;
sortAllEventListenerItemsForType(event->_type); if (toSortListeners)
sortAllEventListenerItemsForType(event->_type);
DispatchGuard guard(_inDispatch); DispatchGuard guard(_inDispatch);

View File

@ -91,7 +91,7 @@ public:
* Also removes all EventListeners marked for deletion from the * Also removes all EventListeners marked for deletion from the
* event dispatcher list. * event dispatcher list.
*/ */
void dispatchEvent(Event* event); void dispatchEvent(Event* event, bool toSortListeners = true);
public: public:
/** Destructor of EventDispatcher */ /** Destructor of EventDispatcher */