Skip to content

Commit

Permalink
键盘老问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujnt committed Aug 20, 2015
1 parent f1614aa commit 5f2728f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
37 changes: 5 additions & 32 deletions CrossApp/dispatcher/CAIMEDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ bool CAIMEDispatcher::attachDelegateWithIME(CAIMEDelegate * pDelegate)
// if old delegate canDetachWithIME return false
// or pDelegate canAttachWithIME return false,
// do nothing.
CC_BREAK_IF(! m_pImpl->m_DelegateWithIme->canDetachWithIME()
|| ! pDelegate->canAttachWithIME());
CC_BREAK_IF(! pDelegate->canAttachWithIME());

// detach first
CAIMEDelegate * pOldDelegate = m_pImpl->m_DelegateWithIme;
Expand Down Expand Up @@ -473,24 +472,11 @@ void CAIMEDispatcher::dispatchKeyboardWillHide(CCIMEKeyboardNotificationInfo& in
{
m_pImpl->m_DelegateWithIme->keyboardWillHide(info);
#if CC_TARGET_PLATFORM==CC_PLATFORM_IOS
m_pImpl->m_DelegateWithIme->canDetachWithIME();
CC_RETURN_IF(! m_pImpl->m_DelegateWithIme->canDetachWithIME());
m_pImpl->m_DelegateWithIme->getKeyBoardHeight(0);
m_pImpl->m_DelegateWithIme->didDetachWithIME();
#endif
}

return;

CAIMEDelegate * pDelegate = 0;
DelegateIter last = m_pImpl->m_DelegateList.end();
for (DelegateIter first = m_pImpl->m_DelegateList.begin(); first != last; ++first)
{
pDelegate = *(first);
if (pDelegate)
{
pDelegate->keyboardWillHide(info);
}
}
}
}

Expand All @@ -501,24 +487,11 @@ void CAIMEDispatcher::dispatchKeyboardDidHide(CCIMEKeyboardNotificationInfo& inf
if(m_pImpl->m_DelegateWithIme){
m_pImpl->m_DelegateWithIme->keyboardDidHide(info);
#if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID
m_pImpl->m_DelegateWithIme->canDetachWithIME();
// m_pImpl->m_DelegateWithIme->getKeyBoardHeight(0);
// m_pImpl->m_DelegateWithIme->didDetachWithIME();
CC_RETURN_IF(!m_pImpl->m_DelegateWithIme->canDetachWithIME());
m_pImpl->m_DelegateWithIme->getKeyBoardHeight(0);
m_pImpl->m_DelegateWithIme->didDetachWithIME();
#endif
}

return;
CAIMEDelegate * pDelegate = 0;
DelegateIter last = m_pImpl->m_DelegateList.end();
for (DelegateIter first = m_pImpl->m_DelegateList.begin(); first != last; ++first)
{

pDelegate = *(first);
if (pDelegate)
{
pDelegate->keyboardDidHide(info);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,12 @@ public void init() {
this.mGLSurfaceView.setCocos2dxRenderer(mCocos2dxRenderer);
this.mGLSurfaceView.setCocos2dxEditText(edittext);

getKeyBoardHeight();
// Set framelayout as the content view
setContentView(framelayout);

getKeyBoardHeight();
}

public static int getKeyBoardHeight()
{
frame.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
Expand All @@ -565,15 +567,12 @@ public void onGlobalLayout() {
keyboardheight =screenHeight- r.bottom;
System.out.println(keyboardheight);

frame.getViewTreeObserver().removeGlobalOnLayoutListener(this);

cocos2dxActivity.mGLSurfaceView.queueEvent(new Runnable()
{
@Override
public void run() {
if (keyboardheight!=0)
{
KeyBoardHeightReturn(keyboardheight);
mCocos2dxRenderer.handleOpenKeyPad();
System.out.println("handleOpenKeyPad");
}
Expand All @@ -582,6 +581,7 @@ public void run() {
mCocos2dxRenderer.handleCloseKeyPad();
System.out.println("handleCloseKeyPad");
}
KeyBoardHeightReturn(keyboardheight);
}
});
}
Expand Down

0 comments on commit 5f2728f

Please sign in to comment.