Skip to content

Instantly share code, notes, and snippets.

@Acen
Created April 25, 2023 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Acen/7245fd17b27fbd4ca86c7420cf10b525 to your computer and use it in GitHub Desktop.
Save Acen/7245fd17b27fbd4ca86c7420cf10b525 to your computer and use it in GitHub Desktop.
some image as button handling - may not be valid due to missing end etc - pasted/cut from larger code blocks
for k, v in ipairs(self.tabs) do
if(v.image ~= nil) then
GUI:Image(v.image.path, v.image.width, v.image.height)
if(v.tooltip ~= nil) then
if(GUI:IsItemHovered()) then
GUI:SetTooltip(v.tooltip)
end
end
GUI:SetCursorPos(0, 0)
GUI:BeginChild('##<replace me>' .. v.name .. 'Image', v.image.width, v.image.height, false, GUI.WindowFlags_NoResize)
if(GUI:InvisibleButton("##<replace me>" .. v.name .. "Button", v.image.width, v.image.height)) then
self.currentTab = k
log("Set current tab to " .. v.name)
end
GUI:EndChild()
end
end
for k, v in ipairs(self.tabs) do
if(v.image ~= nil) then
GUI:PushStyleColor(GUI.Col_Button, 0,0,0,0)
GUI:PushStyleColor(GUI.Col_ButtonHovered, 0,0,0,0.6)
GUI:PushStyleColor(GUI.Col_ButtonActive, 0,0,0,0.8)
-- note this line has some additional colour stuff I was using while testing pre-using pushstyle
if(GUI:ImageButton("##<replace me>" .. v.name .. "Button", v.image.path, v.image.width, v.image.height, 0, 0, 1, 1, 0, 0, 0, 0, 0)) then
self.currentTab = k
end
GUI:PopStyleColor(3)
if(v.tooltip ~= nil) then
if(GUI:IsItemHovered()) then
GUI:SetTooltip(v.tooltip)
end
end
end
self.tabs = {
[1] = {
name = "General",
image = {
path = self.paths.image .. "image.png",
width = 180,
height = 180,
},
tooltip = "General Settings",
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment