diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index 688ab9a80f..49bc100eb3 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -246,7 +246,7 @@ void UICCTextField::setMaxLengthEnabled(bool enable) _maxLengthEnabled = enable; } -bool UICCTextField::isMaxLengthEnabled() +bool UICCTextField::isMaxLengthEnabled()const { return _maxLengthEnabled; } @@ -256,12 +256,12 @@ void UICCTextField::setMaxLength(int length) _maxLength = length; } -int UICCTextField::getMaxLength() +int UICCTextField::getMaxLength()const { return _maxLength; } -int UICCTextField::getCharCount() +int UICCTextField::getCharCount()const { return TextFieldTTF::getCharCount(); } @@ -271,7 +271,7 @@ void UICCTextField::setPasswordEnabled(bool enable) _passwordEnabled = enable; } -bool UICCTextField::isPasswordEnabled() +bool UICCTextField::isPasswordEnabled()const { return _passwordEnabled; } @@ -317,7 +317,7 @@ void UICCTextField::setAttachWithIME(bool attach) _attachWithIME = attach; } -bool UICCTextField::getAttachWithIME() +bool UICCTextField::getAttachWithIME()const { return _attachWithIME; } @@ -327,7 +327,7 @@ void UICCTextField::setDetachWithIME(bool detach) _detachWithIME = detach; } -bool UICCTextField::getDetachWithIME() +bool UICCTextField::getDetachWithIME()const { return _detachWithIME; } @@ -337,7 +337,7 @@ void UICCTextField::setInsertText(bool insert) _insertText = insert; } -bool UICCTextField::getInsertText() +bool UICCTextField::getInsertText()const { return _insertText; } @@ -347,7 +347,7 @@ void UICCTextField::setDeleteBackward(bool deleteBackward) _deleteBackward = deleteBackward; } -bool UICCTextField::getDeleteBackward() +bool UICCTextField::getDeleteBackward()const { return _deleteBackward; } @@ -455,7 +455,7 @@ bool TextField::hitTest(const Vec2 &pt) return false; } -Size TextField::getTouchSize() +Size TextField::getTouchSize()const { return Size(_touchWidth, _touchHeight); } @@ -526,7 +526,7 @@ void TextField::setPlaceHolder(const std::string& value) updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } -const std::string& TextField::getPlaceHolder() +const std::string& TextField::getPlaceHolder()const { return _textFieldRenderer->getPlaceHolder(); } @@ -538,7 +538,7 @@ void TextField::setFontSize(int size) updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } -int TextField::getFontSize() +int TextField::getFontSize()const { return _textFieldRenderer->getSystemFontSize(); } @@ -550,7 +550,7 @@ void TextField::setFontName(const std::string& name) updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } -const std::string& TextField::getFontName() +const std::string& TextField::getFontName()const { return _textFieldRenderer->getSystemFontName(); } @@ -560,7 +560,7 @@ void TextField::didNotSelectSelf() _textFieldRenderer->detachWithIME(); } -const std::string& TextField::getStringValue() +const std::string& TextField::getStringValue()const { return _textFieldRenderer->getString(); } @@ -580,7 +580,7 @@ void TextField::setMaxLengthEnabled(bool enable) _textFieldRenderer->setMaxLengthEnabled(enable); } -bool TextField::isMaxLengthEnabled() +bool TextField::isMaxLengthEnabled()const { return _textFieldRenderer->isMaxLengthEnabled(); } @@ -592,7 +592,7 @@ void TextField::setMaxLength(int length) setText(getStringValue()); } -int TextField::getMaxLength() +int TextField::getMaxLength()const { return _textFieldRenderer->getMaxLength(); } @@ -602,7 +602,7 @@ void TextField::setPasswordEnabled(bool enable) _textFieldRenderer->setPasswordEnabled(enable); } -bool TextField::isPasswordEnabled() +bool TextField::isPasswordEnabled()const { return _textFieldRenderer->isPasswordEnabled(); } @@ -616,7 +616,7 @@ void TextField::setPasswordStyleText(const char *styleText) setText(getStringValue()); } -const char* TextField::getPasswordStyleText() +const char* TextField::getPasswordStyleText()const { return _passwordStyleText.c_str(); } @@ -651,7 +651,7 @@ void TextField::update(float dt) } } -bool TextField::getAttachWithIME() +bool TextField::getAttachWithIME()const { return _textFieldRenderer->getAttachWithIME(); } @@ -661,7 +661,7 @@ void TextField::setAttachWithIME(bool attach) _textFieldRenderer->setAttachWithIME(attach); } -bool TextField::getDetachWithIME() +bool TextField::getDetachWithIME()const { return _textFieldRenderer->getDetachWithIME(); } @@ -671,7 +671,7 @@ void TextField::setDetachWithIME(bool detach) _textFieldRenderer->setDetachWithIME(detach); } -bool TextField::getInsertText() +bool TextField::getInsertText()const { return _textFieldRenderer->getInsertText(); } @@ -681,7 +681,7 @@ void TextField::setInsertText(bool insertText) _textFieldRenderer->setInsertText(insertText); } -bool TextField::getDeleteBackward() +bool TextField::getDeleteBackward()const { return _textFieldRenderer->getDeleteBackward(); } diff --git a/cocos/ui/UITextField.h b/cocos/ui/UITextField.h index 95cc9ca650..8c2ef01c9e 100644 --- a/cocos/ui/UITextField.h +++ b/cocos/ui/UITextField.h @@ -59,22 +59,26 @@ public: void closeIME(); void setMaxLengthEnabled(bool enable); - bool isMaxLengthEnabled(); + bool isMaxLengthEnabled()const; void setMaxLength(int length); - int getMaxLength(); - int getCharCount(); + int getMaxLength()const; + int getCharCount()const; + void setPasswordEnabled(bool enable); - bool isPasswordEnabled(); + bool isPasswordEnabled()const; void setPasswordStyleText(const std::string& styleText); void setPasswordText(const std::string& text); + void setAttachWithIME(bool attach); - bool getAttachWithIME(); + bool getAttachWithIME()const; void setDetachWithIME(bool detach); - bool getDetachWithIME(); + bool getDetachWithIME()const; + void setInsertText(bool insert); - bool getInsertText(); + bool getInsertText()const; + void setDeleteBackward(bool deleteBackward); - bool getDeleteBackward(); + bool getDeleteBackward()const; protected: bool _maxLengthEnabled; int _maxLength; @@ -123,36 +127,48 @@ public: const std::string& fontName, int fontSize); void setTouchSize(const Size &size); - Size getTouchSize(); + Size getTouchSize()const; void setTouchAreaEnabled(bool enable); virtual bool hitTest(const Vec2 &pt); - void setText(const std::string& text); + void setPlaceHolder(const std::string& value); - const std::string& getPlaceHolder(); + const std::string& getPlaceHolder()const; + void setFontSize(int size); - int getFontSize(); + int getFontSize()const; void setFontName(const std::string& name); - const std::string& getFontName(); + const std::string& getFontName()const; + virtual void didNotSelectSelf(); - const std::string& getStringValue(); + + void setText(const std::string& text); + const std::string& getStringValue()const; + virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; + void setMaxLengthEnabled(bool enable); - bool isMaxLengthEnabled(); + bool isMaxLengthEnabled()const; void setMaxLength(int length); - int getMaxLength(); + int getMaxLength()const; + void setPasswordEnabled(bool enable); - bool isPasswordEnabled(); + bool isPasswordEnabled()const; void setPasswordStyleText(const char* styleText); - const char* getPasswordStyleText(); + const char* getPasswordStyleText()const; + virtual void update(float dt) override; - bool getAttachWithIME(); + + bool getAttachWithIME()const; void setAttachWithIME(bool attach); - bool getDetachWithIME(); + bool getDetachWithIME()const; void setDetachWithIME(bool detach); - bool getInsertText(); + + bool getInsertText()const; void setInsertText(bool insertText); - bool getDeleteBackward(); + + bool getDeleteBackward()const; void setDeleteBackward(bool deleteBackward); + CC_DEPRECATED_ATTRIBUTE void addEventListenerTextField(Ref* target, SEL_TextFieldEvent selecor); void addEventListener(const ccTextFieldCallback& callback); @@ -184,6 +200,7 @@ protected: virtual void updateTextureOpacity() override; virtual void updateTextureRGBA() override; void textfieldRendererScaleChangedWithSize(); + virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void adaptRenderers() override;