Move scene up when keypad is opened

Hi guys,

i have a textfield which is at the bottom of screen, so it gets hidden when a keypad is opened, so how to move the scene up when the keypad is opened?

i think @Gurudath is looking for the same solution : I want to moves up keyboard when text view is at the bottom

Hello guys,
From Top of my head, you need to test it to confirm,

auto text=TextField::create("Enter Your Name","fonts/HelveticaNeue.ttf",50);
bg->addChild(text);

text->addEventListener(CC_CALLBACK_2(FbLogin::textFieldEvent, this));

void Login::textFieldEvent(Ref *pSender, TextField::EventType type)
{
    switch (type)
    {
      case TextField::EventType::ATTACH_WITH_IME:
       {
       
       bg->runAction(MoveTo::create(0.3,Vec2(360,1240)));
   }
break;

      case TextField::EventType::DETACH_WITH_IME:
       {
    bg->runAction(Sequence::create(MoveTo::create(0.3,Vec2(360,640)),
    CallFunc::create([&](){
     /// Key Board is not visible now do any checks if you want
   }),NULL));
 }
break;
}

Hope this Helps :smile:

hey, sorry for late reply, didn’t get time to work on it…

i can move the scene up with your code, but the main problem is how to get the height of the keypad, so that we can move the scene up exactly as the height of keyboard. And which also works on multiple device screen sizes.

i did

auto  visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect();

thinking it will give me visible rectangle area minus the keypad areas, but it logs full screen size…

So how to get the area of the visible scene - the keypad, so we can move the scene up accordingly…and which also works on other screen sizes…

MoveTo Action was just a typo for you, i was using this code for something else.

[quote=“mihir77, post:3, topic:28353”]
so that we can move the scene up exactly as the height of keyboard. And which also works on multiple device screen sizes.
[/quote]You need to cook something up, i don’t have that implementation as those were never my needs. I will look into this further maybe this week end.

Regards
Ajay

sure np… :smiley:

let me know if u find how to get the keyboard height, will try something till then…