void UICCTextField::insertText(const char * text, int len) { std::string str_text = text; int str_len = strlen(CCTextFieldTTF::getString()); if (strcmp(text, "\n") != 0) { if (str_len + len > m_nCharacterLength) { int mod = str_len % 3; int offset = (mod == 0) ? 0 : (3 - mod); int amount = str_len + offset; str_text = str_text.substr(0, m_nCharacterLength - amount); CCLOG("str_test = %s", str_text.c_str()); } } CCTextFieldTTF::insertText(str_text.c_str(), len); // password if (m_bIsPassword) { setPswText(m_pInputText->c_str()); } // return if (strcmp(text, "\n") == 0) { if (CCTextFieldTTF::getCharCount() == 0) { CCTextFieldTTF::setPlaceHolder(m_pPlaceHolder->c_str()); } closeIME(); } }
void CCTextInput::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) { CCPoint endPos = pTouch->getLocationInView(); endPos = CCDirector::sharedDirector()->convertToGL(endPos); // 判断是打开输入法还是关闭输入法 isInTextField(endPos) ? openIME() : closeIME(); }
void CCTextInput::insertText(const char * text, int len) { std::string sInsert(text, len); // insert \n means input end int nPos = sInsert.find('\n'); if ((int)sInsert.npos != nPos) { len = nPos; sInsert.erase(nPos); } if (len > 0) { unsigned int inputCharCount = _calcCharCount(sInsert.c_str()) + m_nCharCount; if(inputCharCount>m_limitNum){ return; } m_nCharCount = inputCharCount; std::string sText(*m_pInputText); sText.append(sInsert); setString(sText.c_str()); } if ((int)sInsert.npos == nPos) { return; } // if delegate hasn't processed, detach from IME by default closeIME(); }
bool CCTextInput::ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent) { m_beginPos = pTouch->getLocationInView(); m_beginPos = CCDirector::sharedDirector()->convertToGL(m_beginPos); if(this->isInTextField(m_beginPos)){ return true; } else{ closeIME(); return false; } }
void CursorTextField::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent) { CCPoint endPos = pTouch->getLocationInView(); endPos = CCDirector::sharedDirector()->convertToGL(endPos); if (::abs(endPos.x - m_beginPos.x) > DELTA || ::abs(endPos.y - m_beginPos.y)) { m_beginPos.x = m_beginPos.y = -1; return; } CCLOG("width: %f, height: %f.", getContentSize().width, getContentSize().height); isInTextField(pTouch) ? openIME() : closeIME(); }
Boolean MCScreenDC::close(Boolean force) { if (m_dst_profile != nil) { CMCloseProfile(m_dst_profile); m_dst_profile = nil; } if (m_srgb_profile != nil) { CMCloseProfile(m_srgb_profile); m_srgb_profile = nil; } SetApplicationDockTileMenu(NULL); ReleaseMenu(f_icon_menu); DisposeEventHandlerUPP(s_icon_menu_event_handler_upp); f_icon_menu = NULL; s_icon_menu_event_handler_upp = NULL; showmenu(); //if the menu is hidden, show it. finalisebackdrop(); DisposeRgn(mouseMoveRgn); //dispose the region crated in open() uint2 i; if (ncolors != 0) { int2 i; for (i = 0 ; i < ncolors ; i++) { if (colornames[i] != NULL) MCValueRelease(colornames[i]); } delete colors; delete colornames; delete allocs; } DisposeWindow((WindowPtr)invisibleWin); delete vis; delete mousewindow; delete activewindow; delete lastactivewindow; //TSM - closes down TSM for this app and removes appleevents AERemoveEventHandler(kTextServiceClass, kPos2Offset, TSMPositionToOffsetUPP, False); AERemoveEventHandler(kTextServiceClass, kOffset2Pos, TSMOffsetToPositionUPP, False); AERemoveEventHandler(kTextServiceClass, kUpdateActiveInputArea, TSMUpdateHandlerUPP, False); AERemoveEventHandler(kTextServiceClass, kUnicodeNotFromInputMethod, TSMUnicodeNotFromInputUPP, False); DisposeAEEventHandlerUPP(TSMPositionToOffsetUPP); DisposeAEEventHandlerUPP(TSMOffsetToPositionUPP); DisposeAEEventHandlerUPP(TSMUpdateHandlerUPP); DisposeAEEventHandlerUPP(TSMUnicodeNotFromInputUPP); closeIME(); RemoveReceiveHandler(dragdropUPP, NULL); RemoveTrackingHandler(dragmoveUPP, NULL); DisposeDragTrackingHandlerUPP(dragmoveUPP); DisposeDragReceiveHandlerUPP(dragdropUPP); opened = False; return True; }