Merge pull request #13303 from pandamicro/v3.7.1

Fix issue described in #13284 by reorder state setting and event dispatching
This commit is contained in:
子龙山人 2015-08-11 09:51:06 +08:00
commit 1f14b5895e
2 changed files with 16 additions and 18 deletions

View File

@ -360,19 +360,18 @@ void CheckBox::setupFrontCrossDisableTexture()
_frontCrossDisabledRendererAdaptDirty = true; _frontCrossDisabledRendererAdaptDirty = true;
} }
void CheckBox::onTouchEnded(Touch *touch, Event *unusedEvent)
void CheckBox::releaseUpEvent()
{ {
Widget::releaseUpEvent();
if (_isSelected) if (_isSelected)
{ {
setSelected(false); setSelected(false);
Widget::onTouchEnded(touch, unusedEvent);
unSelectedEvent(); unSelectedEvent();
} }
else else
{ {
setSelected(true); setSelected(true);
Widget::onTouchEnded(touch, unusedEvent);
selectedEvent(); selectedEvent();
} }
} }
@ -391,6 +390,12 @@ void CheckBox::onPressStateChangedToNormal()
_backGroundBoxRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY); _backGroundBoxRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY);
_frontCrossRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY); _frontCrossRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY);
if (_isSelected)
{
_frontCrossRenderer->setVisible(true);
_frontCrossRendererAdaptDirty = true;
}
} }
void CheckBox::onPressStateChangedToPressed() void CheckBox::onPressStateChangedToPressed()
@ -433,6 +438,12 @@ void CheckBox::onPressStateChangedToDisabled()
_frontCrossRenderer->setVisible(false); _frontCrossRenderer->setVisible(false);
_backGroundBoxRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY); _backGroundBoxRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY);
_frontCrossRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY); _frontCrossRenderer->setScale(_backgroundTextureScaleX, _backgroundTextureScaleY);
if (_isSelected)
{
_frontCrossDisabledRenderer->setVisible(true);
_frontCrossDisabledRendererAdaptDirty = true;
}
} }
void CheckBox::setZoomScale(float scale) void CheckBox::setZoomScale(float scale)
@ -453,18 +464,6 @@ void CheckBox::setSelected(bool selected)
} }
_isSelected = selected; _isSelected = selected;
_frontCrossRenderer->setVisible(_isSelected); _frontCrossRenderer->setVisible(_isSelected);
if (_isSelected)
{
if (_bright) {
_frontCrossRenderer->setVisible(true);
_frontCrossRendererAdaptDirty = true;
}
else {
_frontCrossDisabledRenderer->setVisible(true);
_frontCrossDisabledRendererAdaptDirty = true;
}
}
} }
bool CheckBox::isSelected()const bool CheckBox::isSelected()const

View File

@ -232,6 +232,7 @@ public:
//override functions //override functions
virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override;
virtual Size getVirtualRendererSize() const override; virtual Size getVirtualRendererSize() const override;
virtual Node* getVirtualRenderer() override; virtual Node* getVirtualRenderer() override;
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
@ -277,8 +278,6 @@ protected:
void selectedEvent(); void selectedEvent();
void unSelectedEvent(); void unSelectedEvent();
virtual void releaseUpEvent() override;
virtual void onSizeChanged() override; virtual void onSizeChanged() override;
void backGroundTextureScaleChangedWithSize(); void backGroundTextureScaleChangedWithSize();