Search guides and the APICtrl K
  1. API reference
  2. Web editor bridge

webview_cocoa.h

The macOS webview backend (WKWebView).

#include <sonore/webview_cocoa.h>
On this page

Design notes

Written against the Objective-C RUNTIME rather than in Objective-C, so the whole SDK stays plain C++ and a generated project needs no .mm file, no mixed-language build, and no Xcode-specific CMake handling. Every Cocoa call here is objc_msgSend on a class looked up by name, which is exactly what the compiler emits for Objective-C anyway.

Shape mirrors the other backends: an NSView the host embeds, the bridge injected at document start, a ~30 Hz timer, and a message handler.

macOS specifics that shape this file:

  • CLAP's cocoa API uses LOGICAL points, and the OS handles Retina scaling, so set_scale is (correctly) ignored, as it is on Windows.
  • A script message handler is an Objective-C object with a required method. There is no such class in the frameworks, so one is REGISTERED at runtime with a C function as its implementation. That is the standard way to do this without writing Objective-C, and it is why the file needs objc/runtime.h.
  • The webview is added as a subview of the host's NSView and pinned with an autoresizing mask, so a host resizing its window resizes the page without a round trip through set_size.

Types 1

A WKWebView inside an NSView the host embeds.

Functions 8

↑↓ to move↵ to openEvery public name in the headers, and every guide