Okay, so I'm trying to create a script in Derma that will open a pre-defined url.
Basically I've got it to open the example url: [url]www.google.com[/url]
Only problem is, keyboard/mouse input are not working properly.
( btw, new to this. Only started working with Derma a day ago. )
[code]
function url()
f = vgui.Create("HTML")
f:SetPos( 50, 50 )
f:SetSize( ScrW() - 100, ScrH() - 100 )
f:OpenURL( "https://www.google.com" )
f:SetVisible(false)
f:SetDraggable(true)
f:ShowCloseButton(true)
f:SetBackgroundBlur(false)
f:MakePopup()
f:Center()
end
function open()
f:SetVisible(true)
end
function close()
f:SetVisible(false)
end
concommand.Add("quit",close)
concommand.Add("run",open)
hook.Add("Initialize","open url",url)
[/code]
Any help or input is greatly appreciated! Have a wonderful day!
[URL="https://wiki.garrysmod.com/page/Panel/SetKeyboardInputEnabled"]Keyboard[/URL]
[URL="http://wiki.garrysmod.com/page/gui/EnableScreenClicker"]Mouse[/URL]
Not sure if this is what you were looking for though
[QUOTE=Skere_;49288910][URL="https://wiki.garrysmod.com/page/Panel/SetKeyboardInputEnabled"]Keyboard[/URL]
[URL="http://wiki.garrysmod.com/page/gui/EnableScreenClicker"]Mouse[/URL]
Not sure if this is what you were looking for though[/QUOTE]
Yeah, I tried that. No luck. :/
HTML frames don't have the method MakePopup afaik.
Either put it in a DFrame, or use:
[CODE]f:SetMouseInputEnabled(true)
f:SetKeyboardInputEnabled(true)[/CODE]
If the mouse doesn't appear afterwards, use the functions Skere posted alongside those.
[QUOTE=BillyOnWiiU;49289620]HTML frames don't have the method MakePopup afaik.
Either put it in a DFrame, or use:
[CODE]f:SetMouseInputEnabled(true)
f:SetKeyboardInputEnabled(true)[/CODE]
If the mouse doesn't appear afterwards, use the functions Skere posted alongside those.[/QUOTE]
Thank you, looks asthough it's working. below are the following changes I made.
[code]
function url()
f = vgui.Create("HTML")
f:SetPos( 50, 50 )
f:SetSize( ScrW() - 100, ScrH() - 100 )
f:OpenURL( "https://www.google.com" )
f:SetVisible(false)
f:SetKeyboardInputEnabled(true)
f:SetMouseInputEnabled(true)
f:MakePopup()
f:Center()
end
function enable()
f:SetVisible(true)
gui.EnableScreenClicker(true)
end
function disable()
f:SetVisible(false)
gui.EnableScreenClicker(false)
end
concommand.Add("enable_panel",enable)
concommand.Add("disable_panel",disable)
hook.Add("Initialize","url panel",url)
[/code]
One problem though. When I type "disable_panel" the mouse is persistent on my crosshair and my player is unable to move. Any way to fix this?
That's because you are just making the panel invisible rather than removing it completely.
Replace f:SetVisible( false ) with f:Remove().
Also, do not use global functions/variables for such a thing - it's a completely bad practice.
[QUOTE=Netheous;49290252]That's because you are just making the panel invisible rather than removing it completely.
Replace f:SetVisible( false ) with f:Remove().
Also, do not use global functions/variables for such a thing - it's a completely bad practice.[/QUOTE]
Thank you! Extremely good advice for a noobie such as I.
I think I followed your advice, not sure. Like I said. Still a noobie :P
Anyways this is what I've got.
[code]
local DFrame
local LastToggleTime = 0
function VGUI()
if DFrame and DFrame:IsValid() and LastToggleTime < CurTime() then
DFrame:SetVisible( not DFrame:IsVisible())
LastToggleTime = CurTime() + 2
elseif not DFrame or not DFrame:IsValid() then
DFrame = vgui.Create("DFrame")
DFrame:SetPos( 0, 0 )
DFrame:SetSize( ScrW() - 100, ScrH() - 100 )
DFrame:Center()
DFrame:ShowCloseButton(true)
DFrame:SetVisible(false)
DFrame:MakePopup()
html = vgui.Create( "HTML" , DFrame )
html:SetSize( ScrW() - 100, ScrH() - 100 )
html:SetPos( 0, 0 )
html:OpenURL( "https://www.google.com" )
html.Paint = function()
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 0, 0, html:GetWide(), html:GetTall() )
end
end
LastToggleTime = CurTime() + 2
end
function enable()
DFrame:SetVisible(true)
gui.EnableScreenClicker(true)
end
function disable() end
DFrame:Remove()
gui.EnableScreenClicker(false)
end
concommand.Add("enable",enable)
concommand.Add("disable",disable)
hook.Add("Initialize","browser",VGUI)
[/code]
Theres a problem with this though.
concommand doesn't seem to be working. Console recognizes that it's there but then once I attempt to run it I get "Unknown command: enable"
I'm probably doing something stupid.
Anyways, theres that and I have another question. Trying to learn all I can! :D
How would I be able to inplement this into a 3D2D VGUI? Such as Hansome Matt's on his github. URL: [url]https://github.com/HandsomeMatt/3d2d-vgui[/url]
I was able to "kinda" get it to work but I butchard it so hard I decided to restart. XD
Sorry, you need to Log In to post a reply to this thread.