mirror of https://github.com/axmolengine/axmol.git
issue #4557: Updates comments for EventListener::setEnabled/setPaused.
Also does whitespace cleanup and untabify codes. Thanks emacs. :)
This commit is contained in:
parent
7a5dba9eb9
commit
a3214b7505
|
@ -1,18 +1,18 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -22,8 +22,8 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef cocos2d_libs_EventListener_h
|
||||
#define cocos2d_libs_EventListener_h
|
||||
#ifndef __CCEVENTLISTENER_H__
|
||||
#define __CCEVENTLISTENER_H__
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
#include "CCRef.h"
|
||||
|
@ -56,30 +56,30 @@ public:
|
|||
ACCELERATION,
|
||||
CUSTOM
|
||||
};
|
||||
|
||||
|
||||
typedef std::string ListenerID;
|
||||
|
||||
|
||||
protected:
|
||||
/** Constructor */
|
||||
EventListener();
|
||||
|
||||
|
||||
/** Initializes event with type and callback function */
|
||||
bool init(Type t, const ListenerID& listenerID, const std::function<void(Event*)>& callback);
|
||||
public:
|
||||
/** Destructor */
|
||||
virtual ~EventListener();
|
||||
|
||||
|
||||
/** Checks whether the listener is available. */
|
||||
virtual bool checkAvailable() = 0;
|
||||
|
||||
|
||||
/** Clones the listener, its subclasses have to override this method. */
|
||||
virtual EventListener* clone() = 0;
|
||||
|
||||
/** Enables or disables the listener
|
||||
* @note Only listeners with `enabled` state will be able to receive events.
|
||||
* When an listener was initialized, it's enabled by default.
|
||||
* For a `scene graph priority` listener, to receive an event, excepting it was `enabled`,
|
||||
* it also shouldn't be in `pause` state.
|
||||
* An event listener can receive events when it is enabled and is not paused.
|
||||
* paused state is always false when it is a fixed priority listener.
|
||||
*/
|
||||
inline void setEnabled(bool enabled) { _isEnabled = enabled; };
|
||||
|
||||
|
@ -88,12 +88,13 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
/** Sets pause state for the listener
|
||||
/** Sets paused state for the listener
|
||||
* The paused state is only used for scene graph priority listeners.
|
||||
* `EventDispatcher::resumeAllEventListenersForTarget(node)` will set the paused state to `true`,
|
||||
* while `EventDispatcher::pauseAllEventListenersForTarget(node)` will set it to `false`.
|
||||
* @note Fixed priority listeners will never get paused. If a fixed priority doesn't want to receive events,
|
||||
* call `setEnabled(false)` instead.
|
||||
* @note 1) Fixed priority listeners will never get paused. If a fixed priority doesn't want to receive events,
|
||||
* call `setEnabled(false)` instead.
|
||||
* 2) In `Node`'s onEnter and onExit, listeners associated with that node will automatically update their `paused state`.
|
||||
*/
|
||||
inline void setPaused(bool paused) { _paused = paused; };
|
||||
|
||||
|
@ -139,11 +140,11 @@ protected:
|
|||
// Properties
|
||||
//////////////
|
||||
std::function<void(Event*)> _onEvent; /// Event callback function
|
||||
|
||||
|
||||
Type _type; /// Event listener type
|
||||
ListenerID _listenerID; /// Event listener ID
|
||||
bool _isRegistered; /// Whether the listener has been added to dispatcher.
|
||||
|
||||
|
||||
int _fixedPriority; // The higher the number, the higher the priority, 0 is for scene graph base priority.
|
||||
Node* _node; // scene graph based priority
|
||||
bool _paused; // Whether the listener is paused
|
||||
|
@ -153,4 +154,4 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif
|
||||
#endif // __CCEVENTLISTENER_H__
|
||||
|
|
Loading…
Reference in New Issue