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);
|
||||
// some adjustment for margin between the keyboard and the edit box.
|
||||
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 (!rectTracked.intersectsRect(info.end))
|
||||
{
|
||||
|
|
|
@ -404,9 +404,12 @@ static CGPoint convertDesignCoordToScreenCoord(const CCPoint& designCoord, bool
|
|||
|
||||
void CCEditBoxImplIOS::setPosition(const CCPoint& pos)
|
||||
{
|
||||
m_obPosition = pos;
|
||||
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)];
|
||||
if (!m_obPosition.equals(pos))
|
||||
{
|
||||
m_obPosition = pos;
|
||||
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)];
|
||||
}
|
||||
}
|
||||
|
||||
void CCEditBoxImplIOS::setContentSize(const CCSize& size)
|
||||
|
@ -424,7 +427,12 @@ void CCEditBoxImplIOS::setAnchorPoint(const CCPoint& anchorPoint)
|
|||
|
||||
void CCEditBoxImplIOS::visit(void)
|
||||
{
|
||||
|
||||
if(getCCEditBox()->getParent()) {
|
||||
CCPoint p = getCCEditBox()->getParent()->convertToWorldSpace(getCCEditBox()->getPosition());
|
||||
setPosition(p);
|
||||
} else {
|
||||
setPosition(getCCEditBox()->getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
void CCEditBoxImplIOS::openKeyboard()
|
||||
|
|
|
@ -75,6 +75,8 @@ EditBoxTest::EditBoxTest()
|
|||
m_pEditEmail->setInputMode(kEditBoxInputModeEmailAddr);
|
||||
m_pEditEmail->setDelegate(this);
|
||||
addChild(m_pEditEmail);
|
||||
|
||||
this->setPosition(ccp(10, 20));
|
||||
}
|
||||
|
||||
EditBoxTest::~EditBoxTest()
|
||||
|
|
Loading…
Reference in New Issue