axmol/core/ui/UIEditBox/UIEditBox.h

720 lines
21 KiB
C
Raw Normal View History

2019-11-23 20:27:39 +08:00
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2012 James Chen
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2021-12-25 10:04:45 +08:00
https://axis-project.github.io/
2021-12-25 10:04:45 +08:00
2019-11-23 20:27:39 +08:00
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
2021-12-25 10:04:45 +08:00
2019-11-23 20:27:39 +08:00
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
2021-12-25 10:04:45 +08:00
2019-11-23 20:27:39 +08:00
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __UIEDITTEXT_H__
#define __UIEDITTEXT_H__
#include "base/CCIMEDelegate.h"
#include "ui/GUIDefine.h"
#include "ui/UIWidget.h"
#include "ui/UIScale9Sprite.h"
NS_AX_BEGIN
2019-11-23 20:27:39 +08:00
/**
* @addtogroup ui
* @{
*/
2021-12-25 10:04:45 +08:00
namespace ui
{
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
class EditBox;
class EditBoxImpl;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
*@brief Editbox delegate class.
* It's useful when you want to do some customization during Editbox input event
*
* @js NA
* @lua NA
*/
2022-07-16 10:43:05 +08:00
class AX_GUI_DLL EditBoxDelegate
2021-12-25 10:04:45 +08:00
{
public:
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* Reason for ending edit (for platforms where it is known)
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
enum class EditBoxEndAction
2019-11-23 20:27:39 +08:00
{
2021-12-25 10:04:45 +08:00
UNKNOWN,
TAB_TO_NEXT,
TAB_TO_PREVIOUS,
RETURN
};
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
virtual ~EditBoxDelegate() {}
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* This method is called when an edit box gains focus after keyboard is shown.
* @param editBox The edit box object that generated the event.
*/
virtual void editBoxEditingDidBegin(EditBox* /*editBox*/) {}
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* This method is called when the edit box text was changed.
* @param editBox The edit box object that generated the event.
* @param text The new text.
*/
virtual void editBoxTextChanged(EditBox* /*editBox*/, std::string_view /*text*/) {}
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* This method is called when the return button was pressed or the outside area of keyboard was touched.
* @param editBox The edit box object that generated the event.
*/
virtual void editBoxReturn(EditBox* editBox) = 0;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* This method is called when an edit box loses focus after keyboard is hidden.
* @param editBox The edit box object that generated the event.
* @param type The reason why editing ended.
*/
virtual void editBoxEditingDidEndWithAction(EditBox* /*editBox*/, EditBoxEndAction /*action*/) {}
};
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* @brief Class for edit box.
*
* You can use this widget to gather small amounts of text from the user.
*
*/
2022-07-16 10:43:05 +08:00
class AX_GUI_DLL EditBox : public Widget, public IMEDelegate
2021-12-25 10:04:45 +08:00
{
public:
/**
* The popup keyboard return type.
*/
enum class KeyboardReturnType
{
DEFAULT,
DONE,
SEND,
SEARCH,
GO,
NEXT
2019-11-23 20:27:39 +08:00
};
/**
2021-12-25 10:04:45 +08:00
* @brief The EditBox::InputMode defines the type of text that the user is allowed
* to enter.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
enum class InputMode
2019-11-23 20:27:39 +08:00
{
/**
2021-12-25 10:04:45 +08:00
* The user is allowed to enter any text, including line breaks.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
ANY,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* The user is allowed to enter an e-mail address.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
EMAIL_ADDRESS,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* The user is allowed to enter an integer value.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
NUMERIC,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* The user is allowed to enter a phone number.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
PHONE_NUMBER,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* The user is allowed to enter a URL.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
URL,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* The user is allowed to enter a real number value.
* This extends kEditBoxInputModeNumeric by allowing a decimal point.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
DECIMAL,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* The user is allowed to enter any text, except for line breaks.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
SINGLE_LINE,
};
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* @brief The EditBox::InputFlag defines how the input text is displayed/formatted.
*/
enum class InputFlag
{
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* Indicates that the text entered is confidential data that should be
* obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
PASSWORD,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* Indicates that the text entered is sensitive data that the
* implementation must never store into a dictionary or table for use
* in predictive, auto-completing, or other accelerated input schemes.
* A credit card number is an example of sensitive data.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
SENSITIVE,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* This flag is a hint to the implementation that during text editing,
* the initial letter of each word should be capitalized.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
INITIAL_CAPS_WORD,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* This flag is a hint to the implementation that during text editing,
* the initial letter of each sentence should be capitalized.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
INITIAL_CAPS_SENTENCE,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* Capitalize all characters automatically.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
INITIAL_CAPS_ALL_CHARACTERS,
2019-11-23 20:27:39 +08:00
/**
2021-12-25 10:04:45 +08:00
* Lowercase all characters automatically.
2019-11-23 20:27:39 +08:00
*/
2021-12-25 10:04:45 +08:00
LOWERCASE_ALL_CHARACTERS
};
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* create a edit box with size.
* @return An autorelease pointer of EditBox, you don't need to release it only if you retain it again.
*/
static EditBox* create(const Size& size,
Scale9Sprite* normalSprite,
Scale9Sprite* pressedSprite = nullptr,
Scale9Sprite* disabledSprite = nullptr);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* create a edit box with size.
* @return An autorelease pointer of EditBox, you don't need to release it only if you retain it again.
*/
static EditBox* create(const Size& size, std::string_view normalImage, TextureResType texType);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* create a edit box with size.
* @return An autorelease pointer of EditBox, you don't need to release it only if you retain it again.
*/
static EditBox* create(const Size& size,
std::string_view normalImage,
std::string_view pressedImage = "",
std::string_view disabledImage = "",
TextureResType texType = TextureResType::LOCAL);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Constructor.
* @js ctor
* @lua new
*/
EditBox();
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Destructor.
* @js NA
* @lua NA
*/
virtual ~EditBox();
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Init edit box with specified size. This method should be invoked right after constructor.
* @param size The size of edit box.
* @param normal9SpriteBg background image of edit box.
* @param texType the resource type, the default value is TextureResType::LOCAL
* @return Whether initialization is successfully or not.
*/
bool initWithSizeAndBackgroundSprite(const Size& size,
std::string_view normal9SpriteBg,
2021-12-25 10:04:45 +08:00
TextureResType texType = TextureResType::LOCAL);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Init edit box with specified size. This method should be invoked right after constructor.
* @param size The size of edit box.
* @param normal9SpriteBg background image of edit box.
* @return Whether initialization is successfully or not.
*/
bool initWithSizeAndBackgroundSprite(const Size& size, Scale9Sprite* normal9SpriteBg);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Init edit box with specified size. This method should be invoked right after constructor.
* @param size The size of edit box.
* @param normalSprite normal state image of edit box.
* @param pressedSprite pressed state image of edit box.
* @param disabledSprite disabled state image of edit box.
* @return Whether initialization is successfully or not.
*/
bool initWithSizeAndBackgroundSprite(const Size& size,
Scale9Sprite* normalSprite,
Scale9Sprite* pressedSprite,
Scale9Sprite* disabledSprite);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Init edit box with specified size. This method should be invoked right after constructor.
* @param size The size of edit box.
* @param normalImage normal state texture name.
* @param pressedImage pressed state texture name.
* @param disabledImage disabled state texture name.
* @return Whether initialization is successfully or not.
*/
bool initWithSizeAndTexture(const Size& size,
std::string_view normalImage,
std::string_view pressedImage = "",
std::string_view disabledImage = "",
TextureResType texType = TextureResType::LOCAL);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Load textures for edit box.
*
* @param normal normal state texture name.
* @param pressed pressed state texture name.
* @param disabled disabled state texture name.
* @param texType @see `TextureResType`
*/
void loadTextures(std::string_view normal,
std::string_view pressed,
std::string_view disabled = "",
TextureResType texType = TextureResType::LOCAL);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Load normal state texture for edit box.
*
* @param normal normal state texture.
* @param texType @see `TextureResType`
*/
void loadTextureNormal(std::string_view normal, TextureResType texType = TextureResType::LOCAL);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Load pressed state texture for edit box.
*
* @param pressed pressed state texture.
* @param texType @see `TextureResType`
*/
void loadTexturePressed(std::string_view pressed, TextureResType texType = TextureResType::LOCAL);
2021-12-25 10:04:45 +08:00
/**
* Load disabled state texture for edit box.
*
* @param disabled dark state texture.
* @param texType @see `TextureResType`
*/
void loadTextureDisabled(std::string_view disabled, TextureResType texType = TextureResType::LOCAL);
2021-12-25 10:04:45 +08:00
/**
* Sets capInsets for edit box.
*
* @param capInsets capInset in Rect.
*/
void setCapInsets(const Rect& capInsets);
/**
* Sets capInsets for edit box, only the normal state scale9 renderer will be affected.
*
* @param capInsets capInsets in Rect.
*/
void setCapInsetsNormalRenderer(const Rect& capInsets);
/**
* Return the capInsets of normal state scale9sprite.
* @return The normal scale9 renderer capInsets.
*/
const Rect& getCapInsetsNormalRenderer() const;
/**
* Sets capInsets for edit box, only the pressed state scale9 renderer will be affected.
*
* @param capInsets capInsets in Rect
*/
void setCapInsetsPressedRenderer(const Rect& capInsets);
/**
* Return the capInsets of pressed state scale9sprite.
* @return The pressed scale9 renderer capInsets.
*/
const Rect& getCapInsetsPressedRenderer() const;
/**
* Sets capInsets for edit box, only the disabled state scale9 renderer will be affected.
*
* @param capInsets capInsets in Rect.
*/
void setCapInsetsDisabledRenderer(const Rect& capInsets);
/**
* Return the capInsets of disabled state scale9sprite.
* @return The disabled scale9 renderer capInsets.
*/
const Rect& getCapInsetsDisabledRenderer() const;
/**
* Gets/Sets the delegate for edit box.
* @lua NA
*/
void setDelegate(EditBoxDelegate* delegate);
/**
* @js NA
* @lua NA
*/
EditBoxDelegate* getDelegate();
2019-11-23 20:27:39 +08:00
2022-07-16 10:43:05 +08:00
#if AX_ENABLE_SCRIPT_BINDING
2021-12-25 10:04:45 +08:00
/**
* Registers a script function that will be called for EditBox events.
*
* This handler will be removed automatically after onExit() called.
* @code
* -- lua sample
* local function editboxEventHandler(eventType)
* if eventType == "began" then
* -- triggered when an edit box gains focus after keyboard is shown
* elseif eventType == "ended" then
* -- triggered when an edit box loses focus after keyboard is hidden.
* elseif eventType == "changed" then
* -- triggered when the edit box text was changed.
* elseif eventType == "return" then
* -- triggered when the return button was pressed or the outside area of keyboard was touched.
* end
* end
*
* local editbox = EditBox:create(Size(...), Scale9Sprite:create(...))
* editbox = registerScriptEditBoxHandler(editboxEventHandler)
* @endcode
*
* @param handler A number that indicates a lua function.
* @js NA
* @lua NA
*/
void registerScriptEditBoxHandler(int handler);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Unregisters a script function that will be called for EditBox events.
* @js NA
* @lua NA
*/
void unregisterScriptEditBoxHandler();
/**
* get a script Handler
* @js NA
* @lua NA
*/
int getScriptEditBoxHandler() { return _scriptEditBoxHandler; }
2019-11-23 20:27:39 +08:00
2022-07-16 10:43:05 +08:00
#endif // #if AX_ENABLE_SCRIPT_BINDING
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the text entered in the edit box.
* @param pText The given text.
*/
void setText(const char* pText);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the text entered in the edit box.
* @return The text entered in the edit box.
*/
const char* getText() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the font. Only system font is allowed.
* @param pFontName The font name.
* @param fontSize The font size.
*/
void setFont(const char* pFontName, int fontSize);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the font name. Only system font is allowed.
* @param pFontName The font name.
*/
void setFontName(const char* pFontName);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the font name.
* @return The font name.
*/
const char* getFontName() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the font size.
* @param fontSize The font size.
*/
void setFontSize(int fontSize);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the font size.
* @return The font size.
*/
int getFontSize() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the font color of the widget's text.
*/
void setFontColor(const Color3B& color);
void setFontColor(const Color4B& color);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the font color of the widget's text.
*/
const Color4B& getFontColor() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the placeholder's font. Only system font is allowed.
* @param pFontName The font name.
* @param fontSize The font size.
*/
void setPlaceholderFont(const char* pFontName, int fontSize);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the placeholder's font name. only system font is allowed.
* @param pFontName The font name.
*/
void setPlaceholderFontName(const char* pFontName);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the placeholder's font name. only system font is allowed.
* @return The font name.
*/
const char* getPlaceholderFontName() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the placeholder's font size.
* @param fontSize The font size.
*/
void setPlaceholderFontSize(int fontSize);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the placeholder's font size.
* @return The font size.
*/
int getPlaceholderFontSize() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the font color of the placeholder text when the edit box is empty.
*/
void setPlaceholderFontColor(const Color3B& color);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the font color of the placeholder text when the edit box is empty.
*/
void setPlaceholderFontColor(const Color4B& color);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the font color of the placeholder text when the edit box is empty.
*/
const Color4B& getPlaceholderFontColor() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set a text in the edit box that acts as a placeholder when an
* edit box is empty.
* @param pText The given text.
*/
void setPlaceHolder(const char* pText);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get a text in the edit box that acts as a placeholder when an
* edit box is empty.
*/
const char* getPlaceHolder() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the input mode of the edit box.
* @param inputMode One of the EditBox::InputMode constants.
*/
void setInputMode(InputMode inputMode);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the input mode of the edit box.
* @return One of the EditBox::InputMode constants.
*/
InputMode getInputMode() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Sets the maximum input length of the edit box.
* Setting this value enables multiline input mode by default.
* Available on Android, iOS and Windows Phone.
*
* @param maxLength The maximum length.
*/
void setMaxLength(int maxLength);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Gets the maximum input length of the edit box.
*
* @return Maximum input length.
*/
int getMaxLength();
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the input flags that are to be applied to the edit box.
* @param inputFlag One of the EditBox::InputFlag constants.
*/
void setInputFlag(InputFlag inputFlag);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the input flags that are to be applied to the edit box.
* @return One of the EditBox::InputFlag constants.
*/
InputFlag getInputFlag() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the return type that are to be applied to the edit box.
* @param returnType One of the EditBox::KeyboardReturnType constants.
*/
void setReturnType(KeyboardReturnType returnType);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the return type that are to be applied to the edit box.
* @return One of the EditBox::KeyboardReturnType constants.
*/
KeyboardReturnType getReturnType() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Set the text horizontal alignment.
*/
void setTextHorizontalAlignment(TextHAlignment alignment);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Get the text horizontal alignment.
*/
TextHAlignment getTextHorizontalAlignment() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/* override functions */
virtual void setPosition(const Vec2& pos) override;
virtual void setVisible(bool visible) override;
virtual void setContentSize(const Size& size) override;
virtual void setAnchorPoint(const Vec2& anchorPoint) override;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* Returns the "class name" of widget.
*/
virtual std::string getDescription() const override;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
/**
* @js NA
* @lua NA
*/
virtual void draw(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) override;
/**
* @js NA
* @lua NA
*/
virtual void onEnter() override;
/**
* @js NA
* @lua NA
*/
virtual void onExit() override;
/**
* @js NA
* @lua NA
*/
virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info) override;
/**
* @js NA
* @lua NA
*/
virtual void keyboardDidShow(IMEKeyboardNotificationInfo& info) override;
/**
* @js NA
* @lua NA
*/
virtual void keyboardWillHide(IMEKeyboardNotificationInfo& info) override;
/**
* @js NA
* @lua NA
*/
virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info) override;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
void setGlobalZOrder(float globalZOrder) override;
2021-12-25 10:04:45 +08:00
void openKeyboard() const;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
protected:
virtual void releaseUpEvent() override;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
virtual void initRenderer() override;
virtual void onPressStateChangedToNormal() override;
virtual void onPressStateChangedToPressed() override;
virtual void onPressStateChangedToDisabled() override;
virtual void onSizeChanged() override;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
void loadTextureNormal(SpriteFrame* normalSpriteFrame);
void setupNormalTexture(bool textureLoaded);
void loadTexturePressed(SpriteFrame* pressedSpriteFrame);
void setupPressedTexture(bool textureLoaded);
void loadTextureDisabled(SpriteFrame* disabledSpriteFrame);
void setupDisabledTexture(bool textureLoaded);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
void normalTextureScaleChangedWithSize();
void pressedTextureScaleChangedWithSize();
void disabledTextureScaleChangedWithSize();
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
virtual void adaptRenderers() override;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
protected:
void updatePosition(float dt);
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
Scale9Sprite* _normalRenderer = nullptr;
Scale9Sprite* _pressedRenderer = nullptr;
Scale9Sprite* _disabledRenderer = nullptr;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
Rect _capInsetsNormal;
Rect _capInsetsPressed;
Rect _capInsetsDisabled;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
Size _normalTextureSize;
Size _pressedTextureSize;
Size _disabledTextureSize;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
bool _normalTextureLoaded = false;
bool _pressedTextureLoaded = false;
bool _disabledTextureLoaded = false;
bool _normalTextureAdaptDirty = true;
bool _pressedTextureAdaptDirty = true;
bool _disabledTextureAdaptDirty = true;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
std::string _normalFileName;
std::string _pressedFileName;
std::string _disabledFileName;
TextureResType _normalTexType = TextureResType::LOCAL;
TextureResType _pressedTexType = TextureResType::LOCAL;
TextureResType _disabledTexType = TextureResType::LOCAL;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
EditBoxImpl* _editBoxImpl = nullptr;
EditBoxDelegate* _delegate = nullptr;
2019-11-23 20:27:39 +08:00
2021-12-25 10:04:45 +08:00
float _adjustHeight = 0.f;
2022-07-16 10:43:05 +08:00
#if AX_ENABLE_SCRIPT_BINDING
2021-12-25 10:04:45 +08:00
int _scriptEditBoxHandler = 0;
2019-11-23 20:27:39 +08:00
#endif
2021-12-25 10:04:45 +08:00
};
} // namespace ui
2019-11-23 20:27:39 +08:00
// end of ui group
/// @}
NS_AX_END
2019-11-23 20:27:39 +08:00
#endif /* __UIEDITTEXT_H__ */