MCPcopy Create free account
hub / github.com/Tracktion/choc / setupWebView

Method setupWebView

examples/webview_desktop_app.cpp:59–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 }
58
59 void setupWebView()
60 {
61 choc::ui::WebView::Options options;
62 options.enableDebugMode = true;
63 options.enableDebugInspector = false; // Set to true to open dev tools
64
65 options.webviewIsReady = [this](choc::ui::WebView& view)
66 {
67 std::cout << "WebView is ready, setting up bindings and loading content...\n";
68 this->setupJavaScriptBindings (view);
69 view.navigate ("choc://app/");
70 };
71
72 // Custom resource handler for serving local content
73 options.fetchResource = [this](const std::string& path) -> choc::ui::WebView::Options::Resource
74 {
75 return this->handleResourceRequest (path);
76 };
77
78 webView = std::make_unique<choc::ui::WebView>(options);
79 window.setContent (webView->getViewHandle());
80 }
81
82 void setupJavaScriptBindings (choc::ui::WebView& view)
83 {

Callers

nothing calls this directly

Calls 5

handleResourceRequestMethod · 0.95
navigateMethod · 0.45
setContentMethod · 0.45
getViewHandleMethod · 0.45

Tested by

no test coverage detected