I'm referencing a WebPanel through a razor panel. The WebPanel class is loading correctly and no errors are being thrown, however the webpage requested doesn't actually visually display in the UI. I'm using example.com as a test and nothing shows.
using Sandbox;
using Sandbox.UI;
public class BrowserPanel : WebPanel
{
public const string DefaultUrl = "https://example.com";
public BrowserPanel()
{
Style.Width = Length.Percent( 100 );
Style.Height = Length.Percent( 100 );
Style.BackgroundColor = Color.Black.WithAlpha( 0.15f );
}
public void Navigate( string url )
{
Url = string.IsNullOrWhiteSpace( url ) ? DefaultUrl : url;
Log.Info( $"Loading page: {Url}" );
}
public override void OnButtonEvent( ButtonEvent e )
{
// Optional: intercept inputs before/after base call
// Example: close on Escape
if ( e.Pressed && e.Button == "escape" )
{
Delete();
return;
}
base.OnButtonEvent( e );
}
public override void OnKeyTyped( char k )
{
base.OnKeyTyped( k );
Log.Info( $"Typed into web panel: {k}" );
}
protected override void OnFocus( PanelEvent e )
{
base.OnFocus( e );
Log.Info( "Browser panel focused" );
}
protected override void OnBlur( PanelEvent e )
{
base.OnBlur( e );
Log.Info( "Browser panel lost focus" );
}
public override void OnDeleted()
{
base.OnDeleted();
Log.Info( "Browser panel deleted" );
}
}