How To Get The Id Of Widget.newbutton?

Hey,

I have implemented the new widget library into my project and (nearly) everything works just fine. But I can not get the id of widget.newButton anymore.

Here is my code:

local onLevelPickedEvent = function(event) --if event.phase == "release" then print("onLevelPickedEvent") local levelNum = tonumber(event.id) print(levelNum) if (levelNum \<= maxLevel) then print("level "..levelNum.." was selected") storyboard.gotoScene("level"..levelNum, fade) end end --end -- create level buttons via loop for i=1, maxLevel do -- make the button levelPickBtn[i] = widget.newButton { onRelease = onLevelPickedEvent, id = i , label = i, width = 44, height = 39, } print("button") levelPickBtn[i]:setReferencePoint(display.TopLeftReferencePoint) levelPickBtn[i].x = xPos levelPickBtn[i].y = yPos group:insert(levelPickBtn[i]) i = i + 1 if i == 6 or i == 11 or i == 16 then xPos = \_W/5 yPos = yPos + 44 + 16 else xPos = xPos + 44 + 16 end end &nbsp;

Thank you!

Max / CineTek

Hey,

I have implemented the new widget library into my project and (nearly) everything works just fine. But I can not get the id of widget.newButton anymore.

Here is my code:

local onLevelPickedEvent = function(event) --if event.phase == “release” then print(“onLevelPickedEvent”) local levelNum = tonumber(event.id) print(levelNum) if (levelNum <= maxLevel) then print(“level “…levelNum…” was selected”) storyboard.gotoScene(“level”…levelNum, fade) end end --end – create level buttons via loop for i=1, maxLevel do – make the button levelPickBtn[i] = widget.newButton { onRelease = onLevelPickedEvent, id = i , label = i, width = 44, height = 39, } print(“button”) levelPickBtn[i]:setReferencePoint(display.TopLeftReferencePoint) levelPickBtn[i].x = xPos levelPickBtn[i].y = yPos group:insert(levelPickBtn[i]) i = i + 1 if i == 6 or i == 11 or i == 16 then xPos = _W/5 yPos = yPos + 44 + 16 else xPos = xPos + 44 + 16 end end  

Thank you!

Max / CineTek

Change:

local levelNum = tonumber(event.id)

To:

local levelNum = tonumber(event.target.id)

Hey Danny!

Thank you for your help! I did not notice the missing “target” :stuck_out_tongue:

P.S: I am working on a public beta version of Manaiko right now :wink: You will receive further details very soon :slight_smile:

Always welcome :slight_smile:

Hey,

I have implemented the new widget library into my project and (nearly) everything works just fine. But I can not get the id of widget.newButton anymore.

Here is my code:

local onLevelPickedEvent = function(event) --if event.phase == “release” then print(“onLevelPickedEvent”) local levelNum = tonumber(event.id) print(levelNum) if (levelNum <= maxLevel) then print(“level “…levelNum…” was selected”) storyboard.gotoScene(“level”…levelNum, fade) end end --end – create level buttons via loop for i=1, maxLevel do – make the button levelPickBtn[i] = widget.newButton { onRelease = onLevelPickedEvent, id = i , label = i, width = 44, height = 39, } print(“button”) levelPickBtn[i]:setReferencePoint(display.TopLeftReferencePoint) levelPickBtn[i].x = xPos levelPickBtn[i].y = yPos group:insert(levelPickBtn[i]) i = i + 1 if i == 6 or i == 11 or i == 16 then xPos = _W/5 yPos = yPos + 44 + 16 else xPos = xPos + 44 + 16 end end  

Thank you!

Max / CineTek

Change:

local levelNum = tonumber(event.id)

To:

local levelNum = tonumber(event.target.id)

Hey Danny!

Thank you for your help! I did not notice the missing “target” :stuck_out_tongue:

P.S: I am working on a public beta version of Manaiko right now :wink: You will receive further details very soon :slight_smile:

Always welcome :slight_smile: