Advertisement
Vodka51200

button test

Nov 1st, 2021
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | None | 0 0
  1. --[[-------------------------------------------------------------------------
  2.     Button test
  3. ---------------------------------------------------------------------------]]
  4. local DPanel52 = vgui.Create( "DButton" )
  5. DPanel52:SetPos( ScrW()/2-100, 130 ) -- Set the position of the panel
  6. DPanel52:SetSize( 200, 50 ) -- Set the size of the panel
  7. DPanel52:SetText("")
  8. --DPanel52:Center()
  9. DPanel52.isActive = false
  10. DPanel52.Paint = function (self, w, h)
  11.     if self:IsHovered() then
  12.         draw.RoundedBoxEx(15,0,0,w,50,Color(255, 255, 255),true,true,true,true)
  13.         draw.RoundedBox(15,0,0+2,w,h,Color(83, 89, 102, 255))
  14.         draw.SimpleText("Hover Effect Button", "Roboto_24", w * .5, h * .5, Color(87,131,192), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)           
  15.     else
  16.         draw.RoundedBoxEx(15,0,0,w,50,Color(255, 255, 255),true,true,true,true)
  17.         draw.RoundedBox(15,0,0+2,w,h,Color(53, 59, 72, 255))
  18.         draw.SimpleText("Hover Effect Button", "Roboto_24", w * .5, h * .5, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  19.         if self.isActive then
  20.             draw.RoundedBoxEx(15,0,0,w,50,Color(45, 192, 82),true,true,true,true)  
  21.             draw.RoundedBox(15,0,0+2,w,h,Color(53, 59, 72, 255))
  22.             draw.SimpleText("Hover Effect Button", "Roboto_24",w/2,h/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  23.         else
  24.             draw.RoundedBoxEx(15,0,0,w,50,Color(255, 255, 255),true,true,true,true)
  25.             draw.RoundedBox(15,0,0+2,w,h,Color(53, 59, 72, 255))
  26.             draw.SimpleText("Hover Effect Button", "Roboto_24",w/2,h/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  27.            
  28. --Not work--
  29. if self:IsHovered() || self.isActive then
  30.                 draw.RoundedBoxEx(15,0,0,w,50,Color(45, 192, 82),true,true,true,true)  
  31.                 draw.RoundedBox(15,0,0+2,w,h,Color(83, 89, 102, 255))
  32.                 draw.SimpleText("Hover Effect Button", "Roboto_24",w/2,h/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  33.             else
  34.                 draw.RoundedBoxEx(15,0,0,w,50,Color(255, 255, 255),true,true,true,true)
  35.                 draw.RoundedBox(15,0,0+2,w,h,Color(53, 59, 72, 255))
  36.                 draw.SimpleText("Hover Effect Button", "Roboto_24",w/2,h/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  37.             end
  38. --Not work--
  39.         end
  40.     end
  41.  
  42.     -- if self.isActive then
  43.     --  draw.RoundedBoxEx(15,0,0,w,50,Color(45, 192, 82),true,true,true,true)  
  44.     --  draw.RoundedBox(15,0,0+2,w,h,Color(53, 59, 72, 255))
  45.     --  draw.SimpleText("Bouton", "Roboto_24",w/2,h/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  46.     -- else
  47.     --  draw.RoundedBoxEx(15,0,0,w,50,Color(255, 255, 255),true,true,true,true)
  48.     --  draw.RoundedBox(15,0,0+2,w,h,Color(53, 59, 72, 255))
  49.     --  draw.SimpleText("Bouton", "Roboto_24",w/2,h/2,Color(255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
  50.     -- end
  51. end
  52. DPanel52.DoClick = function (self)
  53.         self.isActive = not self.isActive
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement