[Resolved] Moving screen contents when keyboard is onscreen.

I have been trying to find a solution for moving the screen up for keyboard input on fields/info that the keyboard “covers” up when visible. A number of apps do this and I seen this reference to it from iOS developer library.

http://developer.apple.com/library/ios/#DOCUMENTATION/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html

My question is; what is the best way to do this in Corona? I seen the line item here:

http://developer.anscamobile.com/reference/index/nativenewtextfield

that says:

“…you may want to adjust the screen contents when the keyboard is onscreen.”

Any suggestions? Other than setting everything up a static amount? Getting the keyboard height is not an option I think, not avail “yet”…

Thanks,

-Jason [import]uid: 155454 topic_id: 27291 reply_id: 327291[/import]

Hey Jason,

I don’t believe you can get the keyboard height, no, although if this is an iOS app you would normally only move the screen content up if on an iPhone, not an iPad. (At least from what I’ve seen.)

If this is the case then you’d just have to check the keyboard height on the iPhone and move everything up accordingly - 162 pixels, if I recall correctly.

Does this help or are you asking for the actual logic behind moving the graphics when the keyboard is open/closed?

Peach :slight_smile: [import]uid: 52491 topic_id: 27291 reply_id: 110948[/import]

Thanks Peach,

On the right track for the most part. This is for a landscape iPad exclusive app for the time being.

I get the logic. I think I am asking more along the lines of best practice to move the items up…

Do I really have to write script to move each individual object up a set number of pixels or is there a way to group them together… or…?

I’m guessing there is a better way to even transition all the objects together to emulate the smooth slide effect, say for instance like the log in screen for the Facebook app on the iPhone.

Make sense?

Thanks again,
-Jason [import]uid: 155454 topic_id: 27291 reply_id: 110957[/import]

Hey Jason,

Are you using Director or Storyboard?

I ask because if your objects are all in a group, which they would be in either of those cases, you would simply move the group.

(You could also insert all objects into a group and then move it up then back down with transition.to of course.)

Peach :slight_smile: [import]uid: 52491 topic_id: 27291 reply_id: 110972[/import]

Thanks Peach :slight_smile:

Not sure I understand your question. I am using Eclipse to write the code if that helps. And no, nothing is in groups…

I was afraid you would say something like that. I am beginning to think I will have to go back a rewrite a lot of code to put everything into groups.

What is Director or Storyboard? I don’t think you are talking about Adobe… I am normally a flash guy, so be gentle.

Thanks again :slight_smile:

-Jason [import]uid: 155454 topic_id: 27291 reply_id: 111032[/import]

Hey Jason,

Sorry about that; Director isn’t Adobe, no - when you see “Director” around here we’re talking about Director class. It allows you to break up your code into different files for different “scenes”.

For example let’s say you had a game with one level. You’d have main.lua which would move straight into menu.lua which would then let the user press a button and go to level1.lua. etc.

I have a tutorial on it you may find beneficial, it’s very useful. See here; http://corona.techority.com/2010/11/19/how-to-use-scenesscreens-in-corona/

You shouldn’t have to rewrite a bunch of code as you aren’t currently using groups.

What you’d do is create a group;
[lua]myGroup = display.newGroup()[/lua]

Then add each visual element to it;
[lua]myGroup:insert(image1)
myGroup:insert(image2)[/lua]

Then finally you’d do a transition.to on the group to move it up, then back down when ready.

I hope that was gentle enough but please do let me know; I know at first these things can be confusing and if you have questions I haven’t addressed, or further questions about what I have, please don’t hesitate to ask :slight_smile:

Peach [import]uid: 52491 topic_id: 27291 reply_id: 111038[/import]

Thanks Peach,

That was perfect. Wasn’t as much code as we thought. A number of things had to be scrunched together anyway to fit on screen with the keyboard up.

But now I have other questions regarding the keyboard which I have started here:

http://developer.anscamobile.com/node/27414

Thanks again!

-Jason [import]uid: 155454 topic_id: 27291 reply_id: 111371[/import]

I have am hving this issue as well, I tried to insert my textfields into a group but they do not move when I do a transition.to.

Everything else on the screen moves but not the textfields.

Thanks

Larry
[import]uid: 11860 topic_id: 27291 reply_id: 130551[/import]

I have am hving this issue as well, I tried to insert my textfields into a group but they do not move when I do a transition.to.

Everything else on the screen moves but not the textfields.

Thanks

Larry
[import]uid: 11860 topic_id: 27291 reply_id: 130551[/import]