CCEventListenerMouse.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #include "base/CCEventListener.h"
  22. #include "base/CCEventMouse.h"
  23. #ifndef __cocos2d_libs__CCMouseEventListener__
  24. #define __cocos2d_libs__CCMouseEventListener__
  25. /**
  26. * @addtogroup base
  27. * @{
  28. */
  29. NS_CC_BEGIN
  30. class Event;
  31. /** @class EventListenerMouse
  32. * @brief Mouse event listener.
  33. * @js cc._EventListenerMouse
  34. */
  35. class CC_DLL EventListenerMouse : public EventListener
  36. {
  37. public:
  38. static const std::string LISTENER_ID;
  39. /** Create a mouse event listener.
  40. *
  41. * @return An autoreleased EventListenerMouse object.
  42. */
  43. static EventListenerMouse* create();
  44. /// Overrides
  45. virtual EventListenerMouse* clone() override;
  46. virtual bool checkAvailable() override;
  47. std::function<void(EventMouse* event)> onMouseDown;
  48. std::function<void(EventMouse* event)> onMouseUp;
  49. std::function<void(EventMouse* event)> onMouseMove;
  50. std::function<void(EventMouse* event)> onMouseScroll;
  51. CC_CONSTRUCTOR_ACCESS:
  52. EventListenerMouse();
  53. bool init();
  54. };
  55. NS_CC_END
  56. // end of base group
  57. /// @}
  58. #endif /* defined(__cocos2d_libs__CCMouseEventListener__) */