Hello, this is my code. I want to create a search box to change from scene to scene.
Please I need help.
local usuario = display.newRect(-45, 15, 64, 29)
usuario:setFillColor(255,255,255)
usuario.isVisible = true
group:insert(usuario)
--Create our Text Field
local textBox = native.newTextBox(-45, 15, 64, 29)
textBox.isVisible = true
textBox.isEditable = true
textBox.size = 14 --set the character size
--textBox.text = “This is information in\na Text Box.\n\nYou can now edit this box.”
group:insert(textBox)
local buscar = display.newImage(“imagenes/lupa.png”,-45, 15);
buscar.xScale = 0.145;
buscar.yScale = 0.145;
buscar.isVisible = true
group:insert(buscar)
local function searchTextSubmitted(searchText)
print("Search text submitted " … searchText)
– Hide keyboard
native.setKeyboardFocus( nil )
– Hide searchBox
searchField.alpha = 0
searchBarActiveImage.alpha = 0
cancelButton.alpha = 0
resetSearchButton.alpha = 0
– Move tableView down by number of pixels specified in tableViewYDelta variable
transition.to( list, { y= tableViewYDelta, time = 200, delta = “true” } )
searchBarVisible = false
end
function buscar(searchText)
if searchText == naranja then
storyboard.gotoScene( “naranja”, “fade”, 840 )
end
if searchText == Naranja then
storyboard.gotoScene( “naranja”, “fade”, 840 )
end
end
function fieldHandler( textField )
return function( 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.
print(“began”)
--buscar(textField().text)
elseif ( “ended” == event.phase ) then
– This event is called when the user stops editing a field: for example, when they touch a different field
print(“ended”)
buscar(textField().text)
elseif ( “editing” == event.phase ) then
print(“editing”)
--buscar(textField().text)
elseif ( “submitted” == event.phase ) then
– This event occurs when the user presses the “return” key (if available) on the onscreen keyboard
print(“submitted”)
--print( textField().text )
--searchTextSubmitted(textField().text)
--buscar(textField().text)
end
end
end
textBox:addEventListener(“touch”, fieldHandler)
usuario:addEventListener(“touch”, fieldHandler)
thanks