Slimwaffle Posted August 10, 2018 Share Posted August 10, 2018 So I am wanting to know how I go about showing different panels based on the item selected in the tabber widget. So basically if I select the buildings2 tab it shows a different panel that is blank. Because right now it shows the same panel regardless of what I choose. I will post the code I have. --Create a Crafting panel (CRAFTING SCREEN) widget = Widget:Tabber(indent,indent,craftingpanel:GetClientSize().x-indent*2,craftingpanel:GetClientSize().y-indent*2,craftingpanel) widget:AddItem("Buildings1",false) widget:AddItem("Buildings2",false) craftingpanel:SetObject("backgroundcolor",Vec4(0.15,0.15,0.15,1)) GameMenu.tabber = widget local indent = 12 cpanel = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget) cpanel:SetBool("border",false) cpanel2 = Widget:Panel(indent,indent,widget:GetClientSize().x-indent*2,widget:GetClientSize().y-indent*2-30,widget) cpanel2:SetBool("border",false) cpanel2:Hide() GameMenu.cpanel={} GameMenu.cpanel.general=ipanel GameMenu.closecrafting = Widget:Button("Close",widget:GetClientSize().x-72-indent,widget:GetClientSize().y-28-5,72,28,widget) local y=20 local sep=40 --CRAFTING TAB START Widget:Label("Wood Buildings",20,y,200,16,cpanel) y=y+16 GameMenu.wbase = Widget:Button("Foundation",10,y,80,30,cpanel) GameMenu.wwall = Widget:Button("Wall",100,y,80,30,cpanel) GameMenu.wroof = Widget:Button("Roof",190,y,80,30,cpanel) GameMenu.wdoorway = Widget:Button("Doorway",280,y,80,30,cpanel) GameMenu.wwindow = Widget:Button("Window",370,y,80,30,cpanel) y=y+sep Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 10, 2018 Share Posted August 10, 2018 I could be wrong but I believe the tabber is an illusion of sorts that requires the programmer to create the effect of changing tabs by showing and hiding the other gui elements depending on which tab is selected. EDITED -- Added panels to allow for grouping of gui elements to make showing and hiding for the different tabs easier. example: local window = Window:Create("tabber example",0,0,400,300,Window.Titlebar+Window.Center) local context = Context:Create(window) local gui = GUI:Create(context) tabber = Widget:Tabber(20,20,300,150,gui:GetBase()) tabber:AddItem("Buildings1", true) tabber:AddItem("Buildings2",false) tabber:AddItem("Buildings3",false) panel0 = Widget:Panel(0,0,300,150,tabber) wbase = Widget:Button("Foundation",10,60,80,30,panel0) panel1 = Widget:Panel(0,0,300,150,tabber) wwall = Widget:Button("Wall",100,60,80,30,panel1) checkbox = Widget:Button("Checkbox",10,60,76,26,panel1) checkbox:SetString("style","Checkbox") panel1:Hide() panel2 = Widget:Panel(0,0,300,150,tabber) wroof = Widget:Button("Roof",190,60,80,30,panel2) panel2:Hide() while not window:KeyHit(Key.Escape) do if window:Closed() then return false end while EventQueue:Peek() do local event = EventQueue:Wait() if event.source == tabber then if event.data == 0 then panel0:Show() panel1:Hide() panel2:Hide() elseif event.data == 1 then panel0:Hide() panel1:Show() panel2:Hide() else panel0:Hide() panel1:Hide() panel2:Show() end end end context:Sync() end 2 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Slimwaffle Posted August 10, 2018 Author Share Posted August 10, 2018 Thank you soo much mate. After looking this over I was able to rewrite my own code and get this working perfectly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.