TabBar in Widgets 2.0

I’m attempting to convert some code that was working for Widgets v1. The area I’m struggling with is the id field of tab bar buttons.

local tabButtons = { { id = "add", label = "Add", defaultFile = "add.png", overFile = "add-down.png", width = 24, height = 24, onPress = onTabButtonPress, selected = true } }

But when I try to reference them as I did using Widgets v1 (which worked), they always come back as nil.

local function onTabButtonPress(event) print(event.target.id) end

Can someone let me know why? I’m very new to Corona, so it might be something pretty obvious.

Hi @sjarman,

Please try to access it with “_id” in 2.0; this was a minor change in the framework.

[lua]

local function onTabButtonPress( event )

   local pressedTab = event.target

   print( pressedTab._id…" pressed!" )

end

[/lua]

Regards,

Brent

Excellent - that’s working. Thanks!

Hi @sjarman,

Please try to access it with “_id” in 2.0; this was a minor change in the framework.

[lua]

local function onTabButtonPress( event )

   local pressedTab = event.target

   print( pressedTab._id…" pressed!" )

end

[/lua]

Regards,

Brent

Excellent - that’s working. Thanks!