-
Notifications
You must be signed in to change notification settings - Fork 78
(API) Tabs
The tabs object functions a lot like the tabs you would find in an internet browser.
local frame = loveframes.Create("frame")
frame:SetName("Tabs")
frame:SetSize(500, 300)
frame:CenterWithinArea(unpack(demo.centerarea))
local tabs = loveframes.Create("tabs", frame)
tabs:SetPos(5, 30)
tabs:SetSize(490, 265)
local images = {"accept.png", "add.png", "application.png", "building.png", "bin.png", "database.png", "box.png", "brick.png"}
for i=1, 20 do
local image = "resources/images/" .. images[math.random(1, #images)]
local panel = loveframes.Create("panel")
panel.Draw = function()
end
local text1 = loveframes.Create("text", panel)
text1:SetText("Tab " ..i)
text1:SetAlwaysUpdate(true)
text1.Update = function(object, dt)
object:Center()
end
tabs:AddTab("Tab " ..i, panel, "Tab " ..i, image)
end
The tabs object has no unique event callbacks.
Add a tab to the object. Each tab must have a base object. The base object is the second argument provided.
The last two arguments of this method are optional and are used to specify callback functions for the tabbutton object that will be created after calling this method. More specifically, these two callbacks are OnOpened
(called when the tab button becomes active or is "opened") and OnClosed
(called when the tabbutton becomes inactive or is "closed"). The tabbutton object will provide itself as an argument whenever it calls one of these callbacks.
object:AddTab(name[string], object[object], tip[string], image[image], onopened[func], onclosed[func])
Switches to a different tab
object:SwitchToTab(tabnumber[number])
Sets the padding of the object
object:SetPadding(padding[number])
Gets the padding of the object
Returns 1 value: padding [number]
local padding = object:GetPadding()
Sets the height of the tab buttons
object:SetTabHeight(height[number])
Gets the object's tab number
Returns 1 value: tabnumber [number]
local tabnumber = object:GetTabNumber()
Removes a tab from the object's list of tabs
object:RemoveTab(tabid[number])
Sets the amount that the object's scroll buttons will scroll the object's list items by
object:SetButtonScrollAmount(scrollamount[number])
Sets the amount that the object's scroll buttons will scroll the object's list items by
Returns 1 value: scroll amount [number]
local scrollamount = object:GetButtonScrollAmount()
Sets the amount that the mouse wheel will scroll the object's list items by
object:SetMouseWheelScrollAmount(scrollamount[number])
Gets the mouse wheel's scroll amount
Returns 1 value: scroll amount [number]
local scrollamount = object:GetMouseWheelScrollAmount()
Sets whether or not the object should use delta time when calculating how many pixels it's scrollbar needs to move.
object:SetDTScrolling(dtscrolling[boolean])
Gets whether or not the object should use delta time when calculating how many pixels it's scrollbar needs to move
Returns 1 value: dtscrolling [boolean]
local dtscrolling = object:GetDTScrolling()
Sets the object of a tab
object:SetTabObject(tab_id[number], tab_object[object])
These methods are used internally. You should not use them unless you know what you are doing.
Adds scroll buttons to the object.
object:AddScrollButtons()
Gets the entire width of the object's button
Returns 1 value: button width [number]
local width = object:GetWidthOfButtons()