2010-12-31 09:36:53 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
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
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCMOUSE_EVENT_DELEGATE_H__
|
|
|
|
#define __CCMOUSE_EVENT_DELEGATE_H__
|
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
#include "CCEvent.h"
|
|
|
|
#include "CCObject.h"
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
namespace cocos2d {
|
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
class CC_DLL CCMouseEventDelegate
|
2010-12-31 09:36:53 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
//! call the release() in child layer
|
|
|
|
virtual void MouseDestroy() {}
|
|
|
|
//! call the retain() in child layer
|
|
|
|
virtual void MouseKeep() {}
|
|
|
|
|
|
|
|
//
|
|
|
|
// left
|
|
|
|
//
|
|
|
|
/** called when the "mouseDown" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccMouseDown(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
/** called when the "mouseDragged" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccMouseDragged(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
/** called when the "mouseMoved" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
By default, "mouseMoved" is disabled. To enable it, send the "setAcceptsMouseMovedEvents:YES" message to the main window.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccMouseMoved(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
/** called when the "mouseUp" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccMouseUp(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// right
|
|
|
|
//
|
|
|
|
|
|
|
|
/** called when the "rightMouseDown" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccRightMouseDown(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
/** called when the "rightMouseDragged" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccRightMouseDragged(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
/** called when the "rightMouseUp" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccRightMouseUp(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// other
|
|
|
|
//
|
|
|
|
|
|
|
|
/** called when the "otherMouseDown" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccOtherMouseDown(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
/** called when the "otherMouseDragged" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccOtherMouseDragged(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
/** called when the "otherMouseUp" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccOtherMouseUp(CCEvent* pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// scroll wheel
|
|
|
|
//
|
|
|
|
|
|
|
|
/** called when the "scrollWheel" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual bool ccScrollWheel(CCEvent *pEvent) { return false; }
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// enter / exit
|
|
|
|
//
|
|
|
|
|
|
|
|
/** called when the "mouseEntered" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual void ccMouseEntered(CCEvent *pEvent) {}
|
2010-12-31 09:36:53 +08:00
|
|
|
|
|
|
|
/** called when the "mouseExited" event is received.
|
|
|
|
Return YES to avoid propagating the event to other delegates.
|
|
|
|
*/
|
2011-03-07 17:11:57 +08:00
|
|
|
virtual void ccMouseExited(CCEvent *pEvent) {}
|
2010-12-31 09:36:53 +08:00
|
|
|
};
|
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
class CC_DLL CCMouseEventHandle : public CCObject
|
2010-12-31 09:36:53 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~CCMouseEventHandle(void);
|
|
|
|
|
|
|
|
/** delegate */
|
|
|
|
CCMouseEventDelegate* getDelegate();
|
|
|
|
void setDelegate(CCMouseEventDelegate *pDelegate);
|
|
|
|
|
|
|
|
/** initializes a CCMouseEventHandle with a delegate */
|
|
|
|
virtual bool initWithDelegate(CCMouseEventDelegate *pDelegate);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** allocates a CCMouseEventHandle with a delegate */
|
|
|
|
static CCMouseEventHandle* handlerWithDelegate(CCMouseEventDelegate *pDelegate);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CCMouseEventDelegate* m_pDelegate;
|
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace cocos2d
|
|
|
|
|
|
|
|
#endif // __CCMOUSE_EVENT_DELEGATE_H__
|