cocos2d-X 节点(UITextField.h)API
2013-11-27 13:12
375 查看
本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
cocos2d-X 节点(UITextField.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记///cocos2d-x-3.0alpha0/extensions/CocoStudio/GUI/UIWidgets #ifndef __UITEXTFIELD_H__ #define __UITEXTFIELD_H__ #include "../BaseClasses/UIWidget.h" NS_CC_EXT_BEGIN class UICCTextField: public TextFieldTTF, public TextFieldDelegate { public: UICCTextField(); ~UICCTextField(); virtual void onEnter(); // static static UICCTextField* create(const char *placeholder, const char *fontName, float fontSize); // CCTextFieldDelegate virtual bool onTextFieldAttachWithIME(TextFieldTTF *pSender); virtual bool onTextFieldDetachWithIME(TextFieldTTF * pSender); virtual bool onTextFieldInsertText(TextFieldTTF * pSender, const char * text, int nLen); virtual bool onTextFieldDeleteBackward(TextFieldTTF * pSender, const char * delText, int nLen); void insertText(const char* text, int len); void deleteBackward(); void openIME(); void closeIME(); void setMaxLengthEnabled(bool enable); bool isMaxLengthEnabled(); void setMaxLength(int length); int getMaxLength(); int getCharCount(); void setPasswordEnabled(bool enable); bool isPasswordEnabled(); void setPasswordStyleText(const char* styleText); void setPasswordText(const char* text); void setAttachWithIME(bool attach); bool getAttachWithIME(); void setDetachWithIME(bool detach); bool getDetachWithIME(); void setInsertText(bool insert); bool getInsertText(); void setDeleteBackward(bool deleteBackward); bool getDeleteBackward(); protected: bool m_bMaxLengthEnabled; int m_nMaxLength; bool m_bPasswordEnabled; std::string m_strPasswordStyleText; bool m_bAttachWithIME; bool m_bDetachWithIME; bool m_bInsertText; bool m_bDeleteBackward; }; typedef enum { TEXTFIELD_EVENT_ATTACH_WITH_IME, TEXTFIELD_EVENT_DETACH_WITH_IME, TEXTFIELD_EVENT_INDERT_TEXT, TEXTFIELD_EVENT_DELETE_BACKWARD, }TextFiledEventType; typedef void (Object::*SEL_TextFieldEvent)(Object*, TextFiledEventType); #define textfieldeventselector(_SELECTOR) (SEL_TextFieldEvent)(&_SELECTOR) //class UITextField : public UIWidget class UITextField : public UIWidget { public: UITextField(); virtual ~UITextField(); static UITextField* create(); virtual bool init(); virtual void initRenderer(); void setTouchSize(const Size &size); void setText(const char* text); void setPlaceHolder(const char* value); void setFontSize(int size); void setFontName(const char* name); virtual void didNotSelectSelf(); const char* getStringValue(); virtual bool onTouchBegan(const Point &touchPoint); void setMaxLengthEnabled(bool enable); bool isMaxLengthEnabled(); void setMaxLength(int length); int getMaxLength(); void setPasswordEnabled(bool enable); bool isPasswordEnabled(); void setPasswordStyleText(const char* styleText); virtual void update(float dt); bool getAttachWithIME(); void setAttachWithIME(bool attach); bool getDetachWithIME(); void setDetachWithIME(bool detach); bool getInsertText(); void setInsertText(bool insertText); bool getDeleteBackward(); void setDeleteBackward(bool deleteBackward); void addEventListener(Object* target, SEL_TextFieldEvent selecor); virtual void setAnchorPoint(const Point &pt); virtual void setColor(const Color3B &color); virtual void setOpacity(int opacity); /** * Returns the "class name" of widget. //返回 widget的 名字 */ virtual const char* getDescription() const; /*compatibel*/ /** * These methods will be removed */ void setMaxLengthEnable(bool is){setMaxLengthEnabled(is);}; void setPasswordEnable(bool is){setPasswordEnabled(is);}; /************/ virtual const Size& getContentSize() const; virtual Node* getVirtualRenderer(); protected: // event void attachWithIMEEvent(); void detachWithIMEEvent(); void insertTextEvent(); void deleteBackwardEvent(); virtual void onSizeChanged(); void textfieldRendererScaleChangedWithSize(); protected: UICCTextField* _textFieldRenderer; float _touchWidth; float _touchHeight; bool _useTouchArea; Object* _eventListener; SEL_TextFieldEvent _eventSelector; }; NS_CC_EXT_END #endif /* defined(__CocoGUI__UITextField__) */
相关文章推荐
- cocos2d-X 节点(UISlider.h)API
- cocos2d-X 节点(UILoadingBar.h)API
- cocos2d-X 节点(UILabelBMFont.h)API
- cocos2d-X 节点(UILabelAtlas.h)API
- cocos2d-X 节点(UILabel.h)API
- cocos2d-X 节点(UIImageView.h)API
- cocos2d-X 节点(UICheckBox.h)API
- cocos2d-X 节点(UIButton.h)API
- cocos2d-X 节点(UIScrollView.h)API
- cocos2d-X 节点(UIScrollInterface.h)API
- cocos2d-X 节点(UIPageView.h)API
- cocos2d-x 多平台高仿微信打飞机
- 浅谈unix cocos2d-x多线程
- mac下安装websocket,在本机测试cocos2d-x-2.2的WebSocketTest
- cocosdx交叉编译到android使用jni实现java端调用C++方法
- cocos2d-x 环境搭建 for xcode
- Cocos2d-x常用函数及常用宏
- 【cocos2d-x】cocos2d-x学习笔记之二——相关网站记录
- cocos2dx 宏
- (转)cocos2dx 内存管理