Exemple #1
0
        // CCLayer
        public override void OnEnter()
        {
            base.OnEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = new CCRepeatForever(
                (CCActionInterval)CCSequence.FromActions(
                    new CCFadeOut(0.25f),
                    new CCFadeIn(0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_pTextField = CCTextFieldTTF.TextFieldWithPlaceHolder("<click here for input>",
                                                                   TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            AddChild(m_pTextField);

            //m_pTextField.setDelegate(this);


            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
            //    // on android, CCTextFieldTTF cannot auto adjust its position when soft-keyboard pop up
            //    // so we had to set a higher position
            //    m_pTextField->setPosition(new CCPoint(s.width / 2, s.height/2 + 50));
            //#else
            //    m_pTextField->setPosition(ccp(s.width / 2, s.height / 2));
            //#endif

            m_pTrackNode = m_pTextField;
        }
Exemple #2
0
 // CCTextFieldDelegate
 public virtual bool onTextFieldAttachWithIME(CCTextFieldTTF pSender)
 {
     if (m_bAction != null)
     {
         m_pTextField.RunAction(m_pTextFieldAction);
         m_bAction = true;
     }
     return(false);
 }
Exemple #3
0
 public virtual bool onTextFieldDetachWithIME(CCTextFieldTTF pSender)
 {
     if (m_bAction != null)
     {
         m_pTextField.StopAction(m_pTextFieldAction);
         m_pTextField.Opacity = 255;
         m_bAction            = false;
     }
     return(false);
 }
        public static CCTextFieldTTF TextFieldWithPlaceHolder(string placeholder, string fontName, float fontSize)
        {
            var pRet = new CCTextFieldTTF();

            pRet.InitWithString("", fontName, fontSize);
            if (placeholder != null)
            {
                pRet.PlaceHolder = placeholder;
            }
            return(pRet);
        }
        public static CCTextFieldTTF TextFieldWithPlaceHolder(string placeholder, CCSize dimensions, CCTextAlignment alignment, string fontName,
                                                              float fontSize)
        {
            var pRet = new CCTextFieldTTF();

            pRet.InitWithPlaceHolder("", dimensions, alignment, fontName, fontSize);
            if (placeholder != null)
            {
                pRet.PlaceHolder = placeholder;
            }
            return(pRet);
        }
Exemple #6
0
        public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen)
        {
            // if insert enter, treat as default to detach with ime
            if ("\n" == text)
            {
                return(false);
            }

            // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore.
            if (pSender.CharCount >= m_nCharLimit)
            {
                return(true);
            }

            // create a insert text sprite and do some action
            CCLabelTTF label = new CCLabelTTF(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.AddChild(label);
            CCColor3B color = new CCColor3B {
                R = 226, G = 121, B = 7
            };

            label.Color = color;

            // move the sprite from top to position
            CCPoint endPos = pSender.Position;

            if (pSender.CharCount > 0)
            {
                endPos.X += pSender.ContentSize.Width / 2;
            }
            CCSize  inputTextSize = label.ContentSize;
            CCPoint beginPos      = new CCPoint(endPos.X, CCDirector.SharedDirector.WinSize.Height - inputTextSize.Height * 2);

            float duration = 0.5f;

            label.Position = beginPos;
            label.Scale    = 8;

            CCAction seq = CCSequence.FromActions(
                CCSpawn.FromActions(
                    new CCMoveTo(duration, endPos),
                    new CCScaleTo(duration, 1),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
Exemple #7
0
        public override void onClickTrackNode(bool bClicked)
        {
            CCTextFieldTTF pTextField = (CCTextFieldTTF)m_pTrackNode;

            if (bClicked)
            {
                // TextFieldTTFTest be clicked
                CCLog.Log("TextFieldTTFActionTest:CCTextFieldTTF attachWithIME");
                pTextField.AttachWithIME();
            }
            else
            {
                // TextFieldTTFTest not be clicked
                CCLog.Log("TextFieldTTFActionTest:CCTextFieldTTF detachWithIME");
                pTextField.DetachWithIME();
            }
        }
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;

            var pTextField = new CCTextFieldTTF(
                "<click here for input>", TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE
                );

            pTextField.Position = CCDirector.SharedDirector.WinSize.Center;

            pTextField.AutoEdit = true;

            AddChild(pTextField);

            //m_pTrackNode = pTextField;
        }
        // CCLayer
        public override void OnEnter()
        {
            base.OnEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = new CCRepeatForever(
                (CCActionInterval) new CCSequence(
                    new CCFadeOut(0.25f),
                    new CCFadeIn(0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_pTextField = new CCTextFieldTTF("<click here for input>",
                                              TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            AddChild(m_pTextField);

            m_pTrackNode = m_pTextField;
        }
Exemple #10
0
        // CCLayer
        public override void OnEnter()
        {
            base.OnEnter();

            // add CCTextFieldTTF
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCTextFieldTTF pTextField = CCTextFieldTTF.TextFieldWithPlaceHolder("<click here for input>",
                                                                                TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            AddChild(pTextField);

            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
            //    // on android, CCTextFieldTTF cannot auto adjust its position when soft-keyboard pop up
            //    // so we had to set a higher position to make it visable
            //    pTextField->setPosition(ccp(s.width / 2, s.height/2 + 50));
            //#else
            //    pTextField->setPosition(ccp(s.width / 2, s.height / 2));
            //#endif

            m_pTrackNode = pTextField;
        }
Exemple #11
0
        public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen)
        {
            // create a delete text sprite and do some action
            CCLabelTTF label = new CCLabelTTF(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.AddChild(label);

            // move the sprite to fly out
            CCPoint beginPos      = pSender.Position;
            CCSize  textfieldSize = pSender.ContentSize;
            CCSize  labelSize     = label.ContentSize;

            beginPos.X += (textfieldSize.Width - labelSize.Width) / 2.0f;

            int      RAND_MAX = 32767;
            CCRandom rand     = new CCRandom();

            CCSize  winSize        = CCDirector.SharedDirector.WinSize;
            CCPoint endPos         = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + (float)CCRandom.Next() / (2.0f * RAND_MAX)));
            float   duration       = 1;
            float   rotateDuration = 0.2f;
            int     repeatTime     = 5;

            label.Position = beginPos;

            CCAction seq = CCSequence.FromActions(
                CCSpawn.FromActions(
                    new CCMoveTo(duration, endPos),
                    new CCRepeat(
                        new CCRotateBy(rotateDuration, (CCRandom.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
Exemple #12
0
 public virtual bool onDraw(CCTextFieldTTF pSender)
 {
     return false;
 }
Exemple #13
0
        public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen)
        {
            // create a delete text sprite and do some action
            CCLabelTTF label = new CCLabelTTF(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            this.AddChild(label);

            // move the sprite to fly out
            CCPoint beginPos = pSender.Position;
            CCSize textfieldSize = pSender.ContentSize;
            CCSize labelSize = label.ContentSize;
            beginPos.X += (textfieldSize.Width - labelSize.Width) / 2.0f;

            int RAND_MAX = 32767;
            CCRandom rand = new CCRandom();

            CCSize winSize = CCDirector.SharedDirector.WinSize;
            CCPoint endPos = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + (float)CCRandom.Next() / (2.0f * RAND_MAX)));
            float duration = 1;
            float rotateDuration = 0.2f;
            int repeatTime = 5;
            label.Position = beginPos;

            CCAction seq = new CCSequence(
                new CCSpawn(
                    new CCMoveTo (duration, endPos),
                    new CCRepeat (
                        new CCRotateBy (rotateDuration, (CCRandom.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                    new CCFadeOut  (duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));
            label.RunAction(seq);
            return false;
        }
Exemple #14
0
        public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen)
        {
            // if insert enter, treat as default to detach with ime
            if ("\n" == text)
            {
                return false;
            }

            // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore.
            if (pSender.CharCount >= m_nCharLimit)
            {
                return true;
            }

            // create a insert text sprite and do some action
            CCLabelTTF label = new CCLabelTTF(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            this.AddChild(label);
            CCColor3B color = new CCColor3B { R = 226, G = 121, B = 7 };
            label.Color = color;

            // move the sprite from top to position
            CCPoint endPos = pSender.Position;
            if (pSender.CharCount > 0)
            {
                endPos.X += pSender.ContentSize.Width / 2;
            }
            CCSize inputTextSize = label.ContentSize;
            CCPoint beginPos = new CCPoint(endPos.X, CCDirector.SharedDirector.WinSize.Height - inputTextSize.Height * 2);

            float duration = 0.5f;
            label.Position = beginPos;
            label.Scale = 8;

            CCAction seq = new CCSequence(
                new CCSpawn(
                    new CCMoveTo (duration, endPos),
                    new CCScaleTo(duration, 1),
                    new CCFadeOut  (duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));
            label.RunAction(seq);
            return false;
        }
Exemple #15
0
 public virtual bool onTextFieldDetachWithIME(CCTextFieldTTF pSender)
 {
     if (m_bAction != null)
     {
         m_pTextField.StopAction(m_pTextFieldAction);
         m_pTextField.Opacity = 255;
         m_bAction = false;
     }
     return false;
 }
Exemple #16
0
 // CCTextFieldDelegate
 public virtual bool onTextFieldAttachWithIME(CCTextFieldTTF pSender)
 {
     if (m_bAction != null)
     {
         m_pTextField.RunAction(m_pTextFieldAction);
         m_bAction = true;
     }
     return false;
 }
Exemple #17
0
        // CCLayer
        public override void OnEnter()
        {
            base.OnEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = new CCRepeatForever (
                (CCActionInterval)new CCSequence(
                    new CCFadeOut  (0.25f),
                    new CCFadeIn  (0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_pTextField = CCTextFieldTTF.TextFieldWithPlaceHolder("<click here for input>",
            TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            AddChild(m_pTextField);

            //m_pTextField.setDelegate(this);


            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)	
            //    // on android, CCTextFieldTTF cannot auto adjust its position when soft-keyboard pop up
            //    // so we had to set a higher position
            //    m_pTextField->setPosition(new CCPoint(s.width / 2, s.height/2 + 50));
            //#else
            //    m_pTextField->setPosition(ccp(s.width / 2, s.height / 2));
            //#endif

            m_pTrackNode = m_pTextField;
        }
 public static CCTextFieldTTF TextFieldWithPlaceHolder(string placeholder, string fontName, float fontSize)
 {
     var pRet = new CCTextFieldTTF();
     pRet.InitWithString("", fontName, fontSize);
     if (placeholder != null)
     {
         pRet.PlaceHolder = placeholder;
     }
     return pRet;
 }
 public static CCTextFieldTTF TextFieldWithPlaceHolder(string placeholder, CCSize dimensions, CCTextAlignment alignment, string fontName,
                                                       float fontSize)
 {
     var pRet = new CCTextFieldTTF();
     pRet.InitWithPlaceHolder("", dimensions, alignment, fontName, fontSize);
     if (placeholder != null)
     {
         pRet.PlaceHolder = placeholder;
     }
     return pRet;
 }
Exemple #20
0
 public virtual bool onDraw(CCTextFieldTTF pSender)
 {
     return(false);
 }
Exemple #21
0
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;

            var pTextField = new CCTextFieldTTF(
                "<click here for input>", TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE
                );

            pTextField.Position = CCDirector.SharedDirector.WinSize.Center;

            pTextField.AutoEdit = true;

            AddChild(pTextField);

            //m_pTrackNode = pTextField;
        }
Exemple #22
0
        // CCLayer
        public override void OnEnter()
        {
            base.OnEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = new CCRepeatForever(
                (CCActionInterval) new CCSequence(
                                       new CCFadeOut(0.25f),
                                       new CCFadeIn(0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_pTextField = new CCTextFieldTTF("<click here for input>",
                                              TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            AddChild(m_pTextField);

            m_pTrackNode = m_pTextField;
        }