Button.cpp 884 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "Base.h"
  2. #include "Button.h"
  3. namespace gameplay
  4. {
  5. Button::Button()
  6. {
  7. }
  8. Button::~Button()
  9. {
  10. }
  11. Button* Button::create(Theme::Style* style, Properties* properties)
  12. {
  13. Button* button = new Button();
  14. button->initialize(style, properties);
  15. return button;
  16. }
  17. bool Button::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
  18. {
  19. if (!isEnabled())
  20. {
  21. return false;
  22. }
  23. switch (evt)
  24. {
  25. case Touch::TOUCH_PRESS:
  26. _state = Control::ACTIVE;
  27. _dirty = true;
  28. break;
  29. case Touch::TOUCH_RELEASE:
  30. _dirty = true;
  31. setState(Control::NORMAL);
  32. break;
  33. }
  34. return Control::touchEvent(evt, x, y, contactIndex);
  35. }
  36. }