public override void ccTouchEnded(CCTouch pTouch, CCEvent pEvent) { if (m_pTrackNode != null) { return; } CCPoint endPos = pTouch.locationInView(pTouch.view()); endPos = CCDirector.sharedDirector().convertToGL(endPos); float delta = 5.0f; if (Math.Abs(endPos.x - m_beginPos.x) > delta || Math.Abs(endPos.y - m_beginPos.y) > delta) { // not click m_beginPos.x = m_beginPos.y = -1; return; } // decide the trackNode is clicked. CCRect rect; CCPoint point = convertTouchToNodeSpaceAR(pTouch); Debug.WriteLine("KeyboardNotificationLayer:clickedAt(%f,%f)", point.x, point.y); rect = TextInputTestScene.getRect(m_pTrackNode); Debug.WriteLine("KeyboardNotificationLayer:TrackNode at(origin:%f,%f, size:%f,%f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); this.onClickTrackNode(CCRect.CCRectContainsPoint(rect, point)); Debug.WriteLine("----------------------------------"); }
public virtual void keyboardWillShow(CCIMEKeyboardNotificationInfo info) { Debug.WriteLine("TextInputTest:keyboardWillShowAt(origin:%f,%f, size:%f,%f)", info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height); if (m_pTrackNode != null) { return; } CCRect rectTracked = TextInputTestScene.getRect(m_pTrackNode); Debug.WriteLine("TextInputTest:trackingNodeAt(origin:%f,%f, size:%f,%f)", rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height); // if the keyboard area doesn't intersect with the tracking node area, nothing need to do. if (!CCRect.CCRectIntersetsRect(rectTracked, info.end)) { return; } // assume keyboard at the bottom of screen, calculate the vertical adjustment. float adjustVert = CCRect.CCRectGetMaxY(info.end) - CCRect.CCRectGetMinY(rectTracked); Debug.WriteLine("TextInputTest:needAdjustVerticalPosition(%f)", adjustVert); // move all the children node of KeyboardNotificationLayer CCNode ccnoed = new CCNode(); List <CCNode> children = ccnoed.children; CCNode node; int count = children.Count; CCPoint pos; for (int i = 0; i < count; ++i) { node = (CCNode)children[i]; pos = node.position; pos.y += adjustVert; node.position = pos; } }