Example #1
0
        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;
            }
        }