I am making a login/register scene and so I made 2 display groups:
function scene:create(event) -- New player display group newPlayerGroup = display.newGroup(); sceneGroup:insert(newPlayerGroup); createUsernameField = native.newTextField(options) newPlayerGroup:insert(createUsernameField) -- Login display group loginGroup = display.newGroup(); sceneGroup:insert(loginGroup); loginUsernameField = native.newTextField(options) loginGroup:insert(loginUsernameField) loginPasswordField = native.newTextField(options) loginGroup:insert(loginPasswordField) end
Then I set loginGroup.isVisible = false on scene:show.
I also use two widget.newButton to call a function that toggles the visibility of the display groups but the textFields are always visible once they’re shown.
Should I use object:removeSelf() on the textFields?
How do I get the textFields to show/hide accordingly?
How come those example use the fieldHandler function with a return like so:
firstNameField:addEventListener( "userInput", fieldHandler( function() return firstNameField end ) )
and
-- handle the user input --local hasFetchedLocationList = false local function fieldHandler( textField ) return function( event ) print( event.phase, textField().text ) if ( "began" == event.phase ) then elseif ( "ended" == event.phase ) then elseif ( "editing" == event.phase ) then end end end
Instead of the way shown in the newTextField documentation where they just call the function with no returns anywhere. Is it needed? I implemented my textFields without the “return method” and it works fine.
How come those example use the fieldHandler function with a return like so:
firstNameField:addEventListener( "userInput", fieldHandler( function() return firstNameField end ) )
and
-- handle the user input --local hasFetchedLocationList = false local function fieldHandler( textField ) return function( event ) print( event.phase, textField().text ) if ( "began" == event.phase ) then elseif ( "ended" == event.phase ) then elseif ( "editing" == event.phase ) then end end end
Instead of the way shown in the newTextField documentation where they just call the function with no returns anywhere. Is it needed? I implemented my textFields without the “return method” and it works fine.