hi, thanks for supporting corona SDK and this forum, I’ve solved a lot of my problems on corona SDK, myself, being new to corona…
I’ve been hacking this out for about 2hrs now so since it’s a very specific question, about passing params in composer from scene to scene…
I’m getting the text param, not the number and I can’t covert the number to a string because it’s in a table. (there’s probably a scope issue in here somewhere)
I tried passing event.row, event.params.row, setting rowIdx = event.row, rowIdx = tostring(event.row) and even that comes out as a table in tostring()…what gives???
thanks,
daveC
in my current scene, a table, I’m trying to pass the row of the table that is selected by touch, I only need the row. event.row prints, to the console, a number when in this function. I tried reading the docs, stackoverflow, google corona passing parameters with composer, etc…
below is the code from scene4 and we’re going to scene5, took a lot of ingenuity to come up with those names!?!?!
[lua]
local function onRowTouch( event )
– pass the row to access in the next scene too!
local row = event.row – Get reference to the row group –< it is definitely set, I think here
print("-----onRowTouch------- row.index is " … tostring(row.index))
print("-----onRowTouch------- event.target is " … tostring(event.target))
– store the record number in a file and goto the edit scene
local selectedRow = event.row.value
local options =
{
time = 1000,
params = {
row = tostring(selectedRow), –< tried row = event.row.value, event.row, setting it to a local var. ugh…
howdy = “hello” … tostring(selectedRow)
}
}
composer.gotoScene( “view5”, options) - –< goto next scene passing params
end
– The “onRowRender” function may go here (see example under “Inserting Rows”, above)
local function onRowRender( event )
--local phase = event.phase – I don’t know what is this for
local row = event.row – Get reference to the row group
local nameOfSongs
if myData[row.index] ~= nil then
nameOfSongs = myData[row.index]
else
nameOfSongs = “MT”
end
– Cache the row “contentWidth” and “contentHeight” because the row bounds can change as children objects are added
local rowHeight = row.contentHeight
local rowWidth = row.contentWidth
--local songName = display.newText( row, nameOfSongs, 0, 0, native.systemFont, 12) or not found DroidSansMono
local songName = display.newText( row, myData[row.index].name, 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 20
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
–[[
myData[row.index].phone
–]]
local songName = display.newText( row, “Robinson” , 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 75
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
local songName = display.newText( row, myData[row.index].relationship, 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 150
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
local songName = display.newText( row, myData[row.index].hotFlag, 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 170
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
local songName = display.newText( row, myData[row.index].lflag, 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 180
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
local songName = display.newText( row, “$” … myData[row.index].cashAvail, 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 195
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
local songName = display.newText( row, myData[row.index].experience, 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 245
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
local songName = display.newText( row, myData[row.index].counties, 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 275
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
local songName = display.newText( row, myData[row.index].bio, 0, 0, native.systemFont, 12)
songName.anchorX = 0
songName.x = 345
songName.y = rowHeight * 0.5
songName:setTextColor( 0, .12, .98 )
–print("------onRowRender songList[row.index] is " … tostring(songList[row.index] ))
print("------onRowRender myData[row.index] is " … myData[row.index].name … " - " … myData[row.index].phone)
end
[/lua]
here is the console output used to see what the heck I’m missing
[lua]
02:22:25.200 Scroll view was touched
02:22:25.200 (46)-----onRowTouch------- event.target is table: 05A1C208
02:22:25.310 -----onRowTouch------- row.index is 5 –< so it is set in scene4
02:22:25.310 -----onRowTouch------- event.target is table: 05A1C208 –< scene4 ending
02:22:25.310 5a-------------------------< view5 start >----------------------
02:22:25.310 5C------< passed in params of nil
02:22:25.310 5C------< passed in params of hellonil –< hello, the text comes in but not the integer or tostring(integer)
02:22:25.310 5C------ rowIdx is nil
02:22:25.310 5C------(36) params.row is nil
02:22:25.310 5S-------------------------< view5 scene show start >----------------------
02:22:25.310 5S— (50) params passed in?
02:22:25.310 5S(55)------< scene:show phase is will >--------------
02:22:25.310 5S(56)------< passed in params of nil
02:22:25.310 5S(61)------< scene:show >--------------
02:22:25.310 5S(65)------< scene:show will start >--------------
02:22:25.310 5S(85)------< scene:show will display labels and input fields >--------------
02:22:25.515 5S(238)------< scene:show end >--------------
02:22:25.515 5S-------------------------< view5 scene show start >----------------------
02:22:25.515 5S— (50) params passed in?
02:22:25.515 5S(55)------< scene:show phase is did >--------------
02:22:25.515 5S(56)------< passed in params of nil
02:22:25.515 5S(61)------< scene:show >--------------
02:22:25.515 5S(235)------< scene:show did start >--------------
02:22:25.515 5S(238)------< scene:show end >--------------
02:22:25.515 (33)---------scrollListener event.row is nil
02:22:25.515 Scroll view was released
02:22:25.515 (46)-----onRowTouch------- event.target is table: 05A1C208
02:22:25.515 -----onRowTouch------- row.index is 5
02:22:25.515 -----onRowTouch------- event.target is table: 05A1C208
02:22:25.515 5-------------------< view5 scene:hide start >------------------------------
02:22:25.515 5-------------------< view5 scene:hide will >------------------------------
02:22:25.515 5-------------------< view5 scene:hide end >------------------------------
02:22:25.706 5-------------------< view5 scene:hide start >------------------------------
02:22:25.706 5-------------------< view5 scene:hide did >------------------------------
02:22:25.706 5-------------------< view5 scene:hide end >------------------------------
02:22:25.769 5S-------------------------< view5 scene show start >----------------------
[/lua]
here is the output from the console… I get nil or ‘event.target is table: 09DD34A0’ on the numeric value even when I use tostring, the damn ‘hello’ goes through w/o a hitch and I don’t even need that. just used it to see if it actually passed anything.