So I am trying to use something along the lines of DButton or Button. Except Id like to paint my own button with HUDPaint and not use that ugly default button. Any help on this could be greatly appreciated!
You can use [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index6b81.html]GUIMousePressed[/url] to get when the user clicks on a part of the screen. While drawing your custom button and a user clicks, you can use [url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexf685.html]MouseX and MouseY[/url] to get the position of the mouse on the screen, and check if it fall inside the coordinate range of the custom button image. When this is met, you can change your button image to a similar 'pressed' version, then use GUIMouseReleased and the same position check to determine when to run the button's function.
[editline]22nd September 2012[/editline]
I'm pretty sure there are also functions available for getting the mouse position relative to a VGUI or derma panel, as well.
So i would have to use a DImageButton to achieve this rather then hud painting?
Additionally, if you're doing this within a panel, you should use panel:OnMousePressed (and other panel click controls), instead of GUIMousePressed, like so:
[lua]
function yourpanel:OnMousePressed(mc)
//do stuff
end
[/lua]
[editline]22nd September 2012[/editline]
[QUOTE=Swiftone;37765431]So i would have to use a DImageButton to achieve this rather then hud painting?[/QUOTE]
I was explaining how you could make a button without using gmod button functions.
Alright I will give it a shot im sure i will be back for some guidance =)
tyvm btw!!
I am not really sure how to set the coordinates to be inside of a box**button**. I tried to make a test box in the top left corner for easy location testing. Don't laugh im sure I am really far off.
[lua]
function test( xy )
if ( gui.MouseX() 1, 150 ) and
(gui.MouseY() 1, 150) then
print("IT WORKS?")
end
[/lua]
edit: nooooooo not the funny list i said dont laugh!
Lua takes parameters inside of functions such as library/class.funcname(arg, arg), not as (lib.funcname() arg, arg).
I am really sorry but I am not following what you're saying. I don't know my dick from my asshole when it comes to coding :D Can you give me an example on finding cords in the top left side 100X100? Then I think i can figure out how to make my buttons from there i think.
thank you for being patient! and sorry for being a retard =X
Here, I will be nice. This will give you a custom-colored button
[CODE]
local Frame = vgui.Create( "DFrame" )
Frame:SetSize( 150, 75 )
Frame:Center()
Frame:SetTitle( "Title" )
Frame:MakePopup()
local tits = vgui.Create( "DButton" )
tits:SetParent(Frame)
tits:SetSize(159,75)
tits:Center()
tits:SetText("yesss")
tits.Paint = function()
​ surface.SetDrawColor(20,20,20,255)
surface.DrawRect(0,0,tits:GetWide(), tits:GetTall())
surface.SetDrawColor(255,255,255,255)
surface.DrawOutlinedRect(0,-1,tits:GetWide(), tits:GetTall())
end
[/CODE]
Also this [URL]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexdd0a.html[/URL]
Before I had started messing with the mouseX position I had something similar to this sashawolf but I must have had something wrong, anyway thank you so much for this I actually may be able to complete something tonight!
<3
Sorry, you need to Log In to post a reply to this thread.