Garry's Mod Wiki

Revision Difference

DHTML#524482

<panel> <name>DHTML</name> <parent>Awesomium</parent> <description>The DHTML control wraps the internal Awesomium framework, supports calling Javascript functions from Lua, as well as running Lua from within the HTML. Running Lua code is disabled by default.</description> </panel> <example> <description>Creates a DHTML.</description> <code> local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 200 ) frame:SetTitle( "My new Derma frame" ) frame:SetVisible( true ) frame:SetDraggable( true ) frame:Center() --Fill the form with a html page local html = vgui.Create( "DHTML" , frame ) html:Dock( FILL ) html:SetHTML( [[ <input type='submit' onclick='console.log("RUNLUA:print(\"This is called in Lua context\")")' /> ]] ) --Enable the webpage to call lua code html:SetAllowLua( true ) frame:MakePopup() </code> </example> <example> <description>Creates a DHTML and opens Google inside.</description> <code> local frame = vgui.Create("DFrame") frame:SetSize(ScrW() * 0.5, ScrH() * 0.5) frame:SetTitle("HTML Example!") frame:Center() frame:MakePopup() local html = vgui.Create("DHTML", frame) html:Dock(FILL) html:OpenURL("https://www.google.com/") </code> <output><br><image src="dhtmlexample1.png"/><br>A <page>DFrame</page> with a DHTML opening Google inside.</output>⤶ <output>⤶ <image src="dhtmlexample1.png"/>⤶ </output>⤶ </example> # Methods * <page>OnCallback</page>⤶ * <page>GetScrollbars</page>⤶ * <page>SetHTML</page>⤶ * <page>OnBeginLoadingDocument</page>⤶ * <page>OnFinishLoadingDocument</page>⤶ * <page>OnDocumentReady</page>⤶ * <page>OnChildViewCreated</page>⤶ * <page>OnChangeTitle</page>⤶ * <page>OnChangeTargetURL</page>* <page>Panel:OnCallback</page>⤶ * <page>Panel:GetScrollbars</page>⤶ * <page>Panel:SetHTML</page>⤶ * <page>Panel:OnBeginLoadingDocument</page>⤶ * <page>Panel:OnFinishLoadingDocument</page>⤶ * <page>Panel:OnDocumentReady</page>⤶ * <page>Panel:OnChildViewCreated</page>⤶ * <page>Panel:OnChangeTitle</page>⤶ * <page>Panel:OnChangeTargetURL</page>