To add a widget to a Tab, you need to set the parent parameter of the widget during the constructor call to the Tab item you want it to be. Here is an example :
local ui = require "ui"
local win = ui.Window("ui.Tab() constructor sample", "fixed", 314, 216)
local tab = ui.Tab(win, {"Item 1", "Item 2", "Item 3"})
local button = ui.Button(tab.items["Item 1"], "Click me !")
function button:onClick()
ui.msg("You have clicked on Item1's button !")
end
-- show the Window
win:show()
while win.visible do
ui.update()
end
Your question allowed me to discover a huge error in the documentation. Currently it is stated that a parent widget can be either a Window, a Groupbox, or a Tab.
It's wrong: Tab widgets cannot be parents, only their TabItems can.
Thank you for the feedback