Requesting Help - Assigning URL w/ ability to change link
1 replies, posted
Currently working on a small project as an introduction to Derma/VGUI and Lua in general.
I'm currently using [B]DFileBrowser[/B] and have it set to show a DermaMenu() through the OnRightClick() feature.
I have it to show multiple options when you click an item, such as:
Upload Image URL
Preview Image
I want to be able to have it so that when I choose [Upload Image URL] it initializes a TextEntry panel to paste an Imgur link or
any web-hosted image link and be able to save that to that specific item so when you choose [Preview Image] it will simply
open up DHTML to preview that image.
I'm stuck on this as I'm new to Lua and not sure how one might go about storing something that was entered through TextEntry, or is this
something that would require a database of some sorts?
Thanks, any help appreciated.
You don't need to store it, just use textentry:GetValue(). Also, instead of a text entry, you can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/Derma_StringRequest]Derma_StringRequest[/url], it's simpler than making a DFrame and all that just to hold a single text entry.
[CODE]
Derma_StringRequest(
"Upload Image URL", -- title
"Paste Image Link Below", -- description
"", -- default text (none)
function( text )
local frame = vgui.Create( "DFrame" ) -- create a frame
frame:SetTitle( "Image Preview" )
frame:SetSize( ScrW() * 0.75, ScrH() * 0.75 ) -- make it a little bit smaller than the screen
frame:Center()
frame:MakePopup() -- focus it (enables user input)
local html = vgui.Create( "HTML", frame ) -- the html bit
html:Dock( FILL ) -- make it fill the frame
html:OpenURL( text ) -- text is the text entered
end
)
[/CODE]
I'm not sure if forcing people to paste in a URL is really the best idea though. You could just let them find a URL easily without exiting the game by setting the HTML panel to open "http://www.google.com".
Sorry, you need to Log In to post a reply to this thread.