mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-24 13:23:50 -04:00
Merge 0e22a88106
into dcd3244944
This commit is contained in:
commit
f6f79fc8fc
2 changed files with 16 additions and 1 deletions
loader
|
@ -43,6 +43,7 @@ namespace geode {
|
|||
CCTextInputNode* m_input;
|
||||
std::function<void(std::string const&)> m_onInput = nullptr;
|
||||
cocos2d::CCLabelBMFont* m_label = nullptr;
|
||||
bool m_callbackEnabled = true;
|
||||
|
||||
bool init(float width, std::string const& placeholder, std::string const& font);
|
||||
|
||||
|
@ -111,6 +112,10 @@ namespace geode {
|
|||
* the text input
|
||||
*/
|
||||
void setCallback(std::function<void(std::string const&)> onInput);
|
||||
/**
|
||||
* Enables/disables the callback.
|
||||
*/
|
||||
void setCallbackEnabled(bool enabled);
|
||||
/**
|
||||
* Enable/disable the input
|
||||
*/
|
||||
|
@ -137,6 +142,10 @@ namespace geode {
|
|||
* Get the current value of the input
|
||||
*/
|
||||
std::string getString() const;
|
||||
/**
|
||||
* Gets if the callback is enabled or not.
|
||||
*/
|
||||
bool isCallbackEnabled() const;
|
||||
|
||||
/**
|
||||
* Focus this input (activate the cursor)
|
||||
|
|
|
@ -91,7 +91,7 @@ TextInput* TextInput::create(float width, std::string const& placeholder, std::s
|
|||
}
|
||||
|
||||
void TextInput::textChanged(CCTextInputNode* input) {
|
||||
if (m_onInput) {
|
||||
if (m_onInput && m_callbackEnabled) {
|
||||
m_onInput(input->getString());
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +150,9 @@ void TextInput::setCallback(std::function<void(std::string const&)> onInput) {
|
|||
this->setDelegate(this);
|
||||
m_onInput = onInput;
|
||||
}
|
||||
void TextInput::setCallbackEnabled(bool enabled) {
|
||||
m_callbackEnabled = enabled;
|
||||
}
|
||||
void TextInput::setEnabled(bool enabled) {
|
||||
m_input->setTouchEnabled(enabled);
|
||||
m_input->m_placeholderLabel->setOpacity(enabled ? 255 : 150);
|
||||
|
@ -189,6 +192,9 @@ void TextInput::setString(std::string const& str, bool triggerCallback) {
|
|||
std::string TextInput::getString() const {
|
||||
return m_input->getString();
|
||||
}
|
||||
bool TextInput::isCallbackEnabled() const {
|
||||
return m_callbackEnabled;
|
||||
}
|
||||
|
||||
void TextInput::focus() {
|
||||
m_input->onClickTrackNode(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue