docs / webview
gru · 0.7.0
WebView
Optional Windows WebView2 host for embedding HTML inside a Gru window. Native widgets still draw through Raylib; the web view is a child HWND.
When to use it
Use WebView when part of the UI is best done in HTML (docs pane, map, rich editor)
and the rest should stay native Gru widgets and chrome.
Start from cmd/webviewhello or gru new myapp --webview.
Build tags
go run -tags webview2 ./cmd/webviewhello
go run -tags "grudemo,webview2" .
go run ./cmd/gru build webviewhello -webview2
Requires the Microsoft Edge WebView2 Runtime.
Rules
- FillClient · the web view fills the client area below the title bar and resizes with the window.
- Two surfaces · GL draws the Gru tree; WebView is a separate HWND. Hide the HWND when a modal needs hits over that area.
- Focus · hand focus between native widgets and the web view explicitly (see Focus Handoff demo).
Debug
Set GRU_WEBVIEW_DEBUG=1 and use Shift+F11 for stderr traces.
F12 is still the widget inspector.
Demos
- WebView Module Demo
- WebView Focus Handoff
Run with -tags "grudemo,webview2", then Tab to those scenes.
Full guide: WEBVIEW.md · chapter: architecture/webview.md.
Next: Architecture · Start · CLI