mirror of https://github.com/axmolengine/axmol.git
Ensure global Z is correctly set on all child items of EditBox
This commit is contained in:
parent
192a59f39e
commit
ee996a5cfb
|
@ -864,6 +864,15 @@ void EditBox::keyboardDidHide(IMEKeyboardNotificationInfo& /*info*/)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditBox::setGlobalZOrder(float globalZOrder)
|
||||||
|
{
|
||||||
|
Widget::setGlobalZOrder(globalZOrder);
|
||||||
|
if (_editBoxImpl)
|
||||||
|
{
|
||||||
|
_editBoxImpl->setGlobalZOrder(globalZOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if CC_ENABLE_SCRIPT_BINDING
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
void EditBox::registerScriptEditBoxHandler(int handler)
|
void EditBox::registerScriptEditBoxHandler(int handler)
|
||||||
{
|
{
|
||||||
|
|
|
@ -648,6 +648,8 @@ namespace ui {
|
||||||
*/
|
*/
|
||||||
virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info) override;
|
virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info) override;
|
||||||
|
|
||||||
|
void setGlobalZOrder(float globalZOrder) override;
|
||||||
|
|
||||||
void openKeyboard() const;
|
void openKeyboard() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -96,12 +96,14 @@ void EditBoxImplCommon::initInactiveLabels(const Size& size)
|
||||||
_label->setAnchorPoint(Vec2(0.0f,1.0f));
|
_label->setAnchorPoint(Vec2(0.0f,1.0f));
|
||||||
_label->setOverflow(Label::Overflow::CLAMP);
|
_label->setOverflow(Label::Overflow::CLAMP);
|
||||||
_label->setVisible(false);
|
_label->setVisible(false);
|
||||||
|
_label->setGlobalZOrder(_editBox->getGlobalZOrder());
|
||||||
_editBox->addChild(_label, kLabelZOrder);
|
_editBox->addChild(_label, kLabelZOrder);
|
||||||
|
|
||||||
_labelPlaceHolder = Label::create();
|
_labelPlaceHolder = Label::create();
|
||||||
_labelPlaceHolder->setAnchorPoint(Vec2(0.0f, 1.0f));
|
_labelPlaceHolder->setAnchorPoint(Vec2(0.0f, 1.0f));
|
||||||
_labelPlaceHolder->setTextColor(Color4B::GRAY);
|
_labelPlaceHolder->setTextColor(Color4B::GRAY);
|
||||||
_labelPlaceHolder->enableWrap(false);
|
_labelPlaceHolder->enableWrap(false);
|
||||||
|
_labelPlaceHolder->setGlobalZOrder(_editBox->getGlobalZOrder());
|
||||||
_editBox->addChild(_labelPlaceHolder, kLabelZOrder);
|
_editBox->addChild(_labelPlaceHolder, kLabelZOrder);
|
||||||
|
|
||||||
setFont(pDefaultFontName, size.height*2/3);
|
setFont(pDefaultFontName, size.height*2/3);
|
||||||
|
@ -291,6 +293,19 @@ void EditBoxImplCommon::setContentSize(const Size& size)
|
||||||
placeInactiveLabels(_contentSize);
|
placeInactiveLabels(_contentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditBoxImplCommon::setGlobalZOrder(float globalZOrder)
|
||||||
|
{
|
||||||
|
if (_label)
|
||||||
|
{
|
||||||
|
_label->setGlobalZOrder(globalZOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_labelPlaceHolder)
|
||||||
|
{
|
||||||
|
_labelPlaceHolder->setGlobalZOrder(globalZOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EditBoxImplCommon::draw(Renderer* /*renderer*/, const Mat4& /*transform*/, uint32_t flags)
|
void EditBoxImplCommon::draw(Renderer* /*renderer*/, const Mat4& /*transform*/, uint32_t flags)
|
||||||
{
|
{
|
||||||
if(flags)
|
if(flags)
|
||||||
|
|
|
@ -91,6 +91,7 @@ public:
|
||||||
|
|
||||||
virtual void setAnchorPoint(const Vec2& anchorPoint) override {}
|
virtual void setAnchorPoint(const Vec2& anchorPoint) override {}
|
||||||
virtual void setPosition(const Vec2& pos) override {}
|
virtual void setPosition(const Vec2& pos) override {}
|
||||||
|
virtual void setGlobalZOrder(float globalZOrder) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @js NA
|
* @js NA
|
||||||
|
|
|
@ -87,6 +87,8 @@ namespace cocos2d {
|
||||||
virtual void setContentSize(const Size& size) = 0;
|
virtual void setContentSize(const Size& size) = 0;
|
||||||
virtual void setAnchorPoint(const Vec2& anchorPoint) = 0;
|
virtual void setAnchorPoint(const Vec2& anchorPoint) = 0;
|
||||||
|
|
||||||
|
virtual void setGlobalZOrder(float globalZOrder) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check the editbox's position, update it when needed
|
* check the editbox's position, update it when needed
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue