only send delegate update on closing ColorPickPopup

This commit is contained in:
matcool 2024-11-15 16:45:06 -03:00
parent bebc7b4074
commit 3081164600
2 changed files with 12 additions and 7 deletions

View file

@ -39,6 +39,7 @@ namespace geode {
void onOpacitySlider(cocos2d::CCObject* sender);
void onReset(cocos2d::CCObject* sender);
void onClose(cocos2d::CCObject* sender) override;
void textChanged(CCTextInputNode* input) override;
void colorValueChanged(cocos2d::ccColor3B color) override;

View file

@ -335,10 +335,10 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
}
void ColorPickPopup::updateState(CCNode* except) {
#define IF_NOT_EXCEPT(inp, value) \
if (inp->getInputNode() != except) { \
inp->setString(value, false); \
}
#define IF_NOT_EXCEPT(inp, value) \
if (inp->getInputNode() != except) { \
inp->setString(value, false); \
}
IF_NOT_EXCEPT(m_impl->m_rInput, numToString<int>(m_impl->m_color.r));
IF_NOT_EXCEPT(m_impl->m_gInput, numToString<int>(m_impl->m_color.g));
@ -357,9 +357,6 @@ void ColorPickPopup::updateState(CCNode* except) {
}
m_impl->m_resetBtn->setVisible(m_impl->m_originalColor != m_impl->m_color);
m_impl->m_newColorSpr->setColor(to3B(m_impl->m_color));
if (m_impl->m_delegate) {
m_impl->m_delegate->updateColor(m_impl->m_color);
}
}
void ColorPickPopup::onOpacitySlider(CCObject* sender) {
@ -372,6 +369,13 @@ void ColorPickPopup::onReset(CCObject*) {
this->updateState();
}
void ColorPickPopup::onClose(CCObject* sender) {
if (m_impl->m_delegate) {
m_impl->m_delegate->updateColor(m_impl->m_color);
}
Popup::onClose(sender);
}
void ColorPickPopup::textChanged(CCTextInputNode* input) {
if (input->getString().size()) {
switch (input->getTag()) {