• Print

Author Topic: Working with Panels  (Read 4799 times)

0 Members and 1 Guest are viewing this topic.

Offline captain1342

  • Full Member
  • ***
  • Posts: 104
  • Karma: 6
  • Quality is our standard
    • Aperture Development - Quality is our standard
Working with Panels
« on: May 14, 2017, 02:39:18 pm »
So hey I am having a problem with the GMod panels.

I am trying to set the design and the text color of a DButton and i am currently using this:

Code: Lua
  1. local DermaButton = vgui.Create( "DButton", SelectionPanel )
  2. DermaButton:SetText("")
  3. DermaButton:SetPos( 25, 50 )                                   
  4. DermaButton:SetSize( 250, 30 )                                 
  5. DermaButton.DoClick = function()                               
  6.         RunConsoleCommand( "say", "Hi" )
  7. end
  8. function DermaButton:Paint( w, h)
  9.         draw.RoundedBox( 0, 0, 0, w, h, Color( 255, 0, 0, 255 ) )
  10.         draw.Text( {
  11.                 text = "Fighter",
  12.                 color = Color(255,255,255,255),
  13.                 pos = { w/2, h/2 },
  14.                 font = "Gamemode_selection",
  15.                 yalign = TEXT_ALIGN_CENTER,
  16.                 xalign = TEXT_ALIGN_CENTER,
  17.         })
  18. end

but I think there is an other way I don't see. Can someone gives me an example on how to set the text color of a button?

Thanks for reading,
~Cap
Aperture Development
Quality is our standard

Website - GitHub  - Forum  - Steam  - Discord

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Working with Panels
« Reply #1 on: May 14, 2017, 05:17:23 pm »
instead of defining your paint function like that.. try..

Code: [Select]

DermaButton.Paint = function( w, h )
  code code code code
end


Offline captain1342

  • Full Member
  • ***
  • Posts: 104
  • Karma: 6
  • Quality is our standard
    • Aperture Development - Quality is our standard
Re: Working with Panels
« Reply #2 on: May 15, 2017, 08:58:02 am »
Okay ty  ;)

But still how do I set a buttons text design?
Aperture Development
Quality is our standard

Website - GitHub  - Forum  - Steam  - Discord

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Working with Panels
« Reply #3 on: May 15, 2017, 11:49:14 am »
DButtons are inherited from DLabels. So take a look at DLabel methods:

https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb4ac.html

I think you can just do like: button:SetTextColor()

  • Print