REDEditBox.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _RED_EDITBOX_H_
  2. #define _RED_EDITBOX_H_
  3. #include "ui/UIEditBox/UIEditBox.h"
  4. #include "ui/UIEditBox/UIEditBoxImpl.h"
  5. #include "cocos2d.h"
  6. class REDEditBoxDelegate : public cocos2d::ui::EditBoxDelegate {
  7. public:
  8. typedef void (Ref::*Handler)(Ref*);
  9. typedef std::function<void(Ref*)> ccEditBoxCallback;
  10. virtual void editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text) override;
  11. virtual void editBoxReturn(cocos2d::ui::EditBox* editBox) override;
  12. void setTextChangeEvent(ccEditBoxCallback textChangeEvent);
  13. void setReturnEvent(ccEditBoxCallback returnEvent);
  14. protected:
  15. ccEditBoxCallback _textChangeEvent;
  16. ccEditBoxCallback _returnEvent;
  17. };
  18. class REDEditBox : public cocos2d::ui::EditBox {
  19. public:
  20. CREATE_FUNC(REDEditBox)
  21. virtual bool init() override;
  22. bool initWithSizeAndBackgroundSprite(const cocos2d::Size& size, const std::string& pNormal9SpriteBg, TextureResType texType = TextureResType::LOCAL);
  23. void loadBackgroundTexture(const std::string& fileName, TextureResType texType);
  24. void setInsetLeft(float leftInset);
  25. float getInsetLeft() const;
  26. void setInsetTop(float topInset);
  27. float getInsetTop() const;
  28. void setInsetRight(float rightInset);
  29. float getInsetRight() const;
  30. void setInsetBottom(float bottomInset);
  31. float getInsetBottom() const;
  32. };
  33. #endif /* _RED_EDITBOX_H_ */