Advertisement
ssccsscc

[TPT] Interface API. Combobox Demo

Dec 24th, 2019
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. ------------------- Configuration -------------------
  2. local rquiredAPIVersion = 2.42
  3. -----------------------------------------------------
  4. pcall(dofile,"scripts/ssccssccAPI.lua")
  5. if not interface_s or interface_s.Version < rquiredAPIVersion then
  6.   if tpt.confirm("Download and install file", "Interface API (scripts/ssccssccAPI.lua) is required to run script. Download it now?") then
  7.     fs.makeDirectory("scripts")
  8.     tpt.getscript(172, "scripts/ssccssccAPI.lua", 1, 0)
  9.   else
  10.     tpt.log("Script is unavailable due to lack of required files.")
  11.     return
  12.   end
  13. end
  14. local DefaultTheme = interface_s.DefaultTheme
  15. --
  16. function dropDownDemo()
  17.   local MainWindow = interface_s.Components.Window:new(40, 40, 150, 50,true, DefaultTheme.Window)
  18.   MainWindow.AllowResize = false
  19.   MainWindow.AlwaysFocused = true
  20.  
  21.   local label1 = interface_s.Components.Label:new(6,12,"Item: ",DefaultTheme.Label)
  22.  
  23.   local Combo = interface_s.Components.Combobox:new(35,10,50,12,{"Item1","Item2","Item3","Item4","Item5"},DefaultTheme.Combobox)
  24.  
  25.   local OkButton = interface_s.Components.Button:new(95, 32, 50, 12, "Ok", DefaultTheme.Button)
  26.   OkButton:AddHint("Demo hint")
  27.   OkButton.OnPressed = function()
  28.     tpt.log(Combo.Items[Combo.SelectedIndex+1])
  29.   end
  30.  
  31.   local ExitButton = interface_s.Components.Button:new(142, 0, 8, 8,"x", DefaultTheme.Button)
  32.   ExitButton.OnPressed = (function()
  33.     interface_s.RemoveComponent(MainWindow)
  34.   end)
  35.  
  36.   MainWindow:AddComponent(label1)
  37.   MainWindow:AddComponent(Combo)
  38.   MainWindow:AddComponent(OkButton)
  39.   MainWindow:AddComponent(ExitButton)
  40.  
  41.   interface_s.addComponent(MainWindow)
  42. end
  43.  
  44. dropDownDemo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement