Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ui = require("ui")
- -------------------------------------------
- -- General event handler for fields
- -------------------------------------------
- -- You could also assign different handlers for each textfield
- 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
- native.setKeyboardFocus( nil )
- end
- end
- -- Predefine local objects for use later
- local defaultField
- local fields = display.newGroup()
- 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, fieldHandler )
- defaultField.font = native.newFont( native.systemFontBold, inputFontSize )
- defaultField.align = "center"
- -- Add fields to our new group
- fields:insert(defaultField)
- local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
- bkgd:setFillColor( 0, 0, 0, 0 )
- local listener = function( event )
- -- Hide keyboard
- print("tap pressed")
- native.setKeyboardFocus( nil )
- bkgd:removeEventListener("tap", listener) ----------< This is line 196
- bkgd:removeSelf()
- verifyName(defaultField)
- end
- ----------Error Produced----------------
- ERROR: nil key supplied for property lookup.
- stack traceback:
- [C]: ?
- [C]: ?
- ?: in function 'removeEventListener'
- /Users/eric/Documents/CRPG/scene_intro.lua:196: in function </Users/eric/Documents/CRPG/scene_intro.lua:192>
- ?: in function <?:215>
- tap pressed
- Runtime error
- ERROR: nil key supplied for property lookup.
- stack traceback:
- [C]: ?
- [C]: ?
- ?: in function 'removeEventListener'
- /Users/eric/Documents/CRPG/scene_intro.lua:196: in function </Users/eric/Documents/CRPG/scene_intro.lua:192>
- ?: in function <?:215>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement