add TextInput::focus and unfocus

This commit is contained in:
HJfod 2024-07-29 20:58:58 +03:00
parent d49ac634f3
commit 749fdf1ad3
2 changed files with 16 additions and 0 deletions

View file

@ -138,6 +138,15 @@ namespace geode {
*/ */
std::string getString() const; std::string getString() const;
/**
* Focus this input (activate the cursor)
*/
void focus();
/**
* Defocus this input (deactivate the cursor)
*/
void defocus();
CCTextInputNode* getInputNode() const; CCTextInputNode* getInputNode() const;
cocos2d::extension::CCScale9Sprite* getBGSprite() const; cocos2d::extension::CCScale9Sprite* getBGSprite() const;
}; };

View file

@ -191,6 +191,13 @@ std::string TextInput::getString() const {
return m_input->getString(); return m_input->getString();
} }
void TextInput::focus() {
m_input->onClickTrackNode(true);
}
void TextInput::defocus() {
m_input->detachWithIME();
}
CCTextInputNode* TextInput::getInputNode() const { CCTextInputNode* TextInput::getInputNode() const {
return m_input; return m_input;
} }