Garry's Mod Wiki

Revision Difference

DHTML#513218

<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( [[⤶ &amp;lt;input type='submit' onclick='console.log("RUNLUA:print(\"This is called in Lua context\")")' /&amp;gt;⤶ ]] )⤶ ⤶ --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>&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;A <page>DFrame</page> with a DHTML opening Google inside.</output>⤶ ⤶ </example>⤶ ⤶ ⤶ ⤶ ⤶ # Methods ⤶ * {{VGUIElementMethodInternal|OnCallback}}⤶ * {{VGUIElementMethodInternal|GetScrollbars}}⤶ * {{VGUIElementMethodInternal|SetHTML}}⤶ * {{VGUIElementMethodInternal|OnBeginLoadingDocument}}⤶ * {{VGUIElementMethodInternal|OnFinishLoadingDocument}}⤶ * {{VGUIElementMethodInternal|OnDocumentReady}}⤶ * {{VGUIElementMethodInternal|OnChildViewCreated}}⤶ * {{VGUIElementMethodInternal|OnChangeTitle}}⤶ * {{VGUIElementMethodInternal|OnChangeTargetURL}}