transition scenes with textfield. and TabBar help

Hello, I’m new to corona. And I’m working on my first project. I have an app that its first scene is just a textField. I want the user to enter info into the textField and once they submit, it transitions the a new scene. I know this is should be possible but I have no clue what code goes where. I have my native.newTextField in the
function scene:show()
if event.phase == “did”

also, I have no tabBar on the first scene with the textField but I need a tabBar in the scenes after they submit there info with buttons that goto more scenes that all have the tabBar. Can anyone help please

Normally tabBar type apps have the tabbar up all the time.  You generally don’t have a scene without the tabBar.  In this model, you would create the tabBar in main.lua and have it **NOT** be part of the composer scene management.  That way it’s always on top.  If you want to see a good use of this, look at the Business App Sample: https://github.com/coronalabs/business-app-sample

But if you need a screen with out it, you would create the tabBar in each scene and make sure it’s in the scene’s sceneGroup.

However native.* objects cannot be managed by Corona SDK Display groups.  You should remove them in the scene:hide() “will” phase and then create them in the scene:show() “did” phase after the scene is fully on the screen and removed just before the transition starts going off screen(). 

I know this isn’t ideal, but its the nature of how native display objects worth with Corona’s OpenGL canvas.

Rob

Ok i guess including a tabBar in the scenes i need is the best choice.

and thanks. I didn’t know that for native objects. But i was wondering how can i change to the next scene after the user submits there info into the textField? 

im not sure how to use the setReturnKey() function but im guessing its like this:

function scene:show( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "did" then -- The text field's native peice starts hidden, we show it after we are on screen.on txtField = native.newTextField( display.contentCenterX, display.contentCenterY, display.contentWidth \* 0.8, 40 ) txtField.inputType = "default" txtField.align = "center" local font = "HelveticaNeue" or system.nativeFont txtField.font = native.newFont ( font ) txtField.size = 32 txtField.text = "" txtField.placeholder = "Airport Code" txtField.hasBackground = true txtField:setReturnKey(go) sceneGroup:insert(txtField) txtField:addEventListener ( "userInput", textHandler ) end end

and i also tried to use the textHandler() function to compose a new scene after userinput submit but I still get nothing…

function textHandler( event ) if ( event.phase == "began" ) then print( "Begin editing", event.target.text ) elseif (event.phase == "submitted" ) then print( "Final Text: ", event.target.text ) native.setKeyboardFocus( nil ) composer.removeHidden( ) composer.gotoScene( "dataview" ) end end

setReturnKey() just sets the string that shows where the the enter key is.  It doesn’t make the key do anything extra.  You will get an event.phase == “ended” in your listener function and you can use that to trigger your gotoScene() call.

Rob

Thanks, Rob :slight_smile:

Normally tabBar type apps have the tabbar up all the time.  You generally don’t have a scene without the tabBar.  In this model, you would create the tabBar in main.lua and have it **NOT** be part of the composer scene management.  That way it’s always on top.  If you want to see a good use of this, look at the Business App Sample: https://github.com/coronalabs/business-app-sample

But if you need a screen with out it, you would create the tabBar in each scene and make sure it’s in the scene’s sceneGroup.

However native.* objects cannot be managed by Corona SDK Display groups.  You should remove them in the scene:hide() “will” phase and then create them in the scene:show() “did” phase after the scene is fully on the screen and removed just before the transition starts going off screen(). 

I know this isn’t ideal, but its the nature of how native display objects worth with Corona’s OpenGL canvas.

Rob

Ok i guess including a tabBar in the scenes i need is the best choice.

and thanks. I didn’t know that for native objects. But i was wondering how can i change to the next scene after the user submits there info into the textField? 

im not sure how to use the setReturnKey() function but im guessing its like this:

function scene:show( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "did" then -- The text field's native peice starts hidden, we show it after we are on screen.on txtField = native.newTextField( display.contentCenterX, display.contentCenterY, display.contentWidth \* 0.8, 40 ) txtField.inputType = "default" txtField.align = "center" local font = "HelveticaNeue" or system.nativeFont txtField.font = native.newFont ( font ) txtField.size = 32 txtField.text = "" txtField.placeholder = "Airport Code" txtField.hasBackground = true txtField:setReturnKey(go) sceneGroup:insert(txtField) txtField:addEventListener ( "userInput", textHandler ) end end

and i also tried to use the textHandler() function to compose a new scene after userinput submit but I still get nothing…

function textHandler( event ) if ( event.phase == "began" ) then print( "Begin editing", event.target.text ) elseif (event.phase == "submitted" ) then print( "Final Text: ", event.target.text ) native.setKeyboardFocus( nil ) composer.removeHidden( ) composer.gotoScene( "dataview" ) end end

setReturnKey() just sets the string that shows where the the enter key is.  It doesn’t make the key do anything extra.  You will get an event.phase == “ended” in your listener function and you can use that to trigger your gotoScene() call.

Rob

Thanks, Rob :slight_smile: