From 749fdf1ad376950e71a851a3051d4e6dd28c3fdf Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:58:58 +0300 Subject: [PATCH] add TextInput::focus and unfocus --- loader/include/Geode/ui/TextInput.hpp | 9 +++++++++ loader/src/ui/nodes/TextInput.cpp | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/loader/include/Geode/ui/TextInput.hpp b/loader/include/Geode/ui/TextInput.hpp index 1d65b30d..f771c675 100644 --- a/loader/include/Geode/ui/TextInput.hpp +++ b/loader/include/Geode/ui/TextInput.hpp @@ -138,6 +138,15 @@ namespace geode { */ std::string getString() const; + /** + * Focus this input (activate the cursor) + */ + void focus(); + /** + * Defocus this input (deactivate the cursor) + */ + void defocus(); + CCTextInputNode* getInputNode() const; cocos2d::extension::CCScale9Sprite* getBGSprite() const; }; diff --git a/loader/src/ui/nodes/TextInput.cpp b/loader/src/ui/nodes/TextInput.cpp index fb47ad5b..5c80d308 100644 --- a/loader/src/ui/nodes/TextInput.cpp +++ b/loader/src/ui/nodes/TextInput.cpp @@ -191,6 +191,13 @@ std::string TextInput::getString() const { return m_input->getString(); } +void TextInput::focus() { + m_input->onClickTrackNode(true); +} +void TextInput::defocus() { + m_input->detachWithIME(); +} + CCTextInputNode* TextInput::getInputNode() const { return m_input; }