Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function enterName()
- -- graphic stuff, ignore this
- print (" ENTER NAME ")
- print (" SAVEDISK:" .. FinalOverWriteDisk)
- group.mm.elements.Text_header.text = ( rosetta:getString("Enter a name") )
- group.mm.groups.Text_1.isVisible = false
- group.mm.groups.Text_2.isVisible = false
- group.mm.groups['GarbageGroup'].isVisible = false
- group.mm.groups['DiskManager1'].isVisible = false
- group.mm.groups['DiskManager2'].isVisible = false
- group.mm.groups['DiskManager3'].isVisible = false
- group.mm.groups['YesNo'].isVisible = false
- local ui = require("ui")
- -------------------------------------------
- -- General event handler for fields
- -------------------------------------------
- -- You could also assign different handlers for each textfield
- local fields = display.newGroup()
- local function fieldHandler( event )
- if ( "began" == event.phase ) then
- -- This is the "keyboard has appeared" event
- -- In some cases you may want to adjust the interface when the keyboard appears.
- elseif ( "ended" == event.phase ) then
- -- This event is called when the user stops editing a field: for example, when they touch a different field
- elseif ( "submitted" == event.phase ) then
- -- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard
- -- Hide keyboard
- playerName = defaultField.text
- fields:removeSelf()
- native.setKeyboardFocus()
- -- textField
- --id of the field on which to set the keyboard focus, or nil to hide the keyboard.
- verifyName()
- end
- end
- -- Predefine local objects for use later
- -------------------------------------------
- -- *** Buttons Presses ***
- -------------------------------------------
- -- Default Button Pressed
- --defaultField:removeSelf()
- -- fields:remove( defaultField )
- -- Number Button Pressed
- ------------------------------------------
- -- *** Create native input textfields ***
- -------------------------------------------
- -- Note: currently this feature works in device builds or Xcode simulator builds only
- -- Note: currently this feature works in device builds only
- local isAndroid = "Android" == system.getInfo("platformName")
- local inputFontSize = 18
- local inputFontHeight = 30
- if isAndroid then
- -- Android text fields have more chrome. It's either make them bigger, or make the font smaller.
- -- We'll do both
- inputFontSize = 14
- inputFontHeight = 42
- end
- defaultField = native.newTextField( 10, 80, 300, 30); defaultField:addEventListener("userInput", fieldHandler)
- defaultField.font = native.newFont( native.systemFontBold, inputFontSize )
- defaultField.align = "center"
- -- Add fields to our new group
- fields:insert(defaultField)
- -------------------------------------------
- -- *** Add field labels ***
- -------------------------------------------
- -- "Remove Default" Button
- -- Position the buttons on screen
- -- Create a Background touch event
- -------------------------------------------
- local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
- bkgd:setFillColor( 0, 0, 0, 0 ) -- set Alpha = 0 so it doesn't cover up our buttons/fields
- -- Tapping screen dismisses the keyboard
- -- Needed for the Number and Phone textFields since there is
- -- no return key to clear focus.
- local function listener( event )
- -- Hide keyboard
- print("tap pressed")
- native.setKeyboardFocus(fields.defaultField)
- playerName = defaultField.text
- bkgd:removeEventListener("tap", listener)
- bkgd:removeSelf()
- end
- -- Determine if running on Corona Simulator
- -- Add listener to background for user "tap"
- bkgd:addEventListener( "tap", listener )
- verifyName()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement