mirror of https://github.com/axmolengine/axmol.git
fixed #1750: [iOS] CCEditBox's position is incorrect when it's added to a non-fullscreen CCNode.
This commit is contained in:
parent
201fda1f58
commit
efdb9180e4
|
@ -280,7 +280,10 @@ void CCEditBox::keyboardWillShow(CCIMEKeyboardNotificationInfo& info)
|
||||||
CCRect rectTracked = getRect(this);
|
CCRect rectTracked = getRect(this);
|
||||||
// some adjustment for margin between the keyboard and the edit box.
|
// some adjustment for margin between the keyboard and the edit box.
|
||||||
rectTracked.origin.y -= 4;
|
rectTracked.origin.y -= 4;
|
||||||
|
if (m_pParent != NULL)
|
||||||
|
{
|
||||||
|
rectTracked.origin = m_pParent->convertToWorldSpace(rectTracked.origin);
|
||||||
|
}
|
||||||
// if the keyboard area doesn't intersect with the tracking node area, nothing needs to be done.
|
// if the keyboard area doesn't intersect with the tracking node area, nothing needs to be done.
|
||||||
if (!rectTracked.intersectsRect(info.end))
|
if (!rectTracked.intersectsRect(info.end))
|
||||||
{
|
{
|
||||||
|
|
|
@ -403,11 +403,14 @@ static CGPoint convertDesignCoordToScreenCoord(const CCPoint& designCoord, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEditBoxImplIOS::setPosition(const CCPoint& pos)
|
void CCEditBoxImplIOS::setPosition(const CCPoint& pos)
|
||||||
|
{
|
||||||
|
if (!m_obPosition.equals(pos))
|
||||||
{
|
{
|
||||||
m_obPosition = pos;
|
m_obPosition = pos;
|
||||||
CCPoint designCoord = ccp(pos.x - m_tContentSize.width * m_obAnchorPoint.x, pos.y + m_tContentSize.height * (1 - m_obAnchorPoint.y));
|
CCPoint designCoord = ccp(pos.x - m_tContentSize.width * m_obAnchorPoint.x, pos.y + m_tContentSize.height * (1 - m_obAnchorPoint.y));
|
||||||
[m_systemControl setPosition:convertDesignCoordToScreenCoord(designCoord, m_bInRetinaMode)];
|
[m_systemControl setPosition:convertDesignCoordToScreenCoord(designCoord, m_bInRetinaMode)];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CCEditBoxImplIOS::setContentSize(const CCSize& size)
|
void CCEditBoxImplIOS::setContentSize(const CCSize& size)
|
||||||
{
|
{
|
||||||
|
@ -424,7 +427,12 @@ void CCEditBoxImplIOS::setAnchorPoint(const CCPoint& anchorPoint)
|
||||||
|
|
||||||
void CCEditBoxImplIOS::visit(void)
|
void CCEditBoxImplIOS::visit(void)
|
||||||
{
|
{
|
||||||
|
if(getCCEditBox()->getParent()) {
|
||||||
|
CCPoint p = getCCEditBox()->getParent()->convertToWorldSpace(getCCEditBox()->getPosition());
|
||||||
|
setPosition(p);
|
||||||
|
} else {
|
||||||
|
setPosition(getCCEditBox()->getPosition());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEditBoxImplIOS::openKeyboard()
|
void CCEditBoxImplIOS::openKeyboard()
|
||||||
|
|
|
@ -75,6 +75,8 @@ EditBoxTest::EditBoxTest()
|
||||||
m_pEditEmail->setInputMode(kEditBoxInputModeEmailAddr);
|
m_pEditEmail->setInputMode(kEditBoxInputModeEmailAddr);
|
||||||
m_pEditEmail->setDelegate(this);
|
m_pEditEmail->setDelegate(this);
|
||||||
addChild(m_pEditEmail);
|
addChild(m_pEditEmail);
|
||||||
|
|
||||||
|
this->setPosition(ccp(10, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
EditBoxTest::~EditBoxTest()
|
EditBoxTest::~EditBoxTest()
|
||||||
|
|
Loading…
Reference in New Issue