Lignum

Bedrock Radio Button

Jun 20th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. BackgroundColour = colours.white
  2. ActiveBackgroundColour = colours.green
  3. TextColour = colours.black
  4. Text = "<Unnamed>"
  5. Friends = {}
  6. AutoWidth = true
  7. Selected = false
  8. Enabled = true
  9.  
  10. OnUpdate = function(self, value)
  11.   if value == "Text" and self.AutoWidth then
  12.     self.Width = #self.Text + 2
  13.   end
  14.  
  15.   if value == "Selected" and self.Selected then
  16.     for _,v in pairs(self.Friends) do
  17.       v.Selected = false
  18.     end
  19.   end
  20. end
  21.  
  22. OnLoad = function(self)
  23.   if self.AutoWidth then
  24.     self.Width = #self.Text + 2
  25.   end
  26.  
  27.   self.Height = 1
  28. end
  29.  
  30. OnDraw = function(self, x, y)
  31.   Drawing.DrawCharacters(x, y, self.Selected and "#" or "o", self.Selected and colours.green or colours.lightGrey, colours.white)
  32.   Drawing.DrawCharacters(x + 2, y, self.Text, self.TextColour, colours.transparent)
  33. end
  34.  
  35. Click = function(self, event, side, x, y)
  36.   if self.Visible and not self.IgnoreClick and self.Enabled and event ~= "mouse_scroll" then
  37.     self.Selected = true
  38.  
  39.     if self.OnSelectionChange then
  40.       self:OnSelectionChange(self.Selected)
  41.     end
  42.  
  43.     return true
  44.   end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment