### Install Saucer Desktop Module with FetchContent Source: https://saucer.app/misc/modules Installs the saucer-desktop module using FetchContent. Ensure to link the library after making it available. ```cmake FetchContent_Declare( saucer-desktop GIT_REPOSITORY https://github.com/saucer/desktop GIT_TAG ) FetchContent_MakeAvailable(saucer-desktop) target_link_libraries(${PROJECT_NAME} [PRIVATE|PUBLIC] saucer::desktop) ``` -------------------------------- ### Use Stable Natives (Qt Example) Source: https://saucer.app/misc/native Include the stable native header for your platform and use the `native` object to interact with platform features. This example demonstrates setting the zoom factor for a Qt webview. ```cpp #include coco::stray start(saucer::application *) { // ... auto native = webview->native(); native.webview->setZoomFactor(5); // ... } ``` -------------------------------- ### Use Unstable Natives (Qt Example) Source: https://saucer.app/misc/native Include the private header for unstable natives and access the implementation directly using `native()`. This example shows muting audio on a platform web page, but is not recommended for general use. ```cpp #include coco::stray start(saucer::application *) { // ... auto *const native = webview->native(); native->platform->web_page->setAudioMuted(true); // ... } ``` -------------------------------- ### Handle Load State Change Event Source: https://saucer.app/webview/events Subscribe to events emitted when the loading state of a web page changes. The state parameter indicates whether loading has started or finished. ```cpp webview->on([](const saucer::state&) { // ... }); ``` -------------------------------- ### CMakeLists.txt for Hello World Project Source: https://saucer.app/getting-started/hello-world This CMakeLists.txt file sets up a C++23 project, defines an executable, and fetches the saucer library using FetchContent. ```cmake cmake_minimum_required(VERSION 3.21) project(hello-world LANGUAGES CXX VERSION 1.0.0) # -------------------------------------------------------------------------------------------------------- # Create executable # -------------------------------------------------------------------------------------------------------- add_executable(${PROJECT_NAME}) target_sources(${PROJECT_NAME} PRIVATE "src/main.cpp") target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 23 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON) # -------------------------------------------------------------------------------------------------------- # Link libraries # -------------------------------------------------------------------------------------------------------- include(FetchContent) FetchContent_Declare( saucer GIT_REPOSITORY "https://github.com/saucer/saucer" GIT_TAG v8.0.4 ) FetchContent_MakeAvailable(saucer) target_link_libraries(${PROJECT_NAME} PRIVATE saucer::saucer) ``` -------------------------------- ### main.cpp for Hello World Application Source: https://saucer.app/getting-started/hello-world This C++ code defines the entry point for a saucer application, creates a window and a smartview, exposes JavaScript functions, and sets the webview URL. ```cpp #include #include coco::stray start(saucer::application *app) { auto window = saucer::window::create(app).value(); auto webview = saucer::smartview::create({.window = window}); window->set_title("Hello World!"); webview->expose("call_me", [&](double a, double b) { std::println("Called with: a = {}, b = {}", a, b); return a + b; }); webview->expose("call_me_too", [&]() -> coco::task { auto random = *co_await webview->evaluate("Math.random()"); std::println("Random: {}", random); co_return random; }); webview->set_url("https://saucer.app"); window->show(); co_await app->finish(); } int main() { return saucer::application::create({.id = "hello-world"})->run(start); } ``` -------------------------------- ### Fetch Saucer using FetchContent Source: https://saucer.app/getting-started Fetch the Saucer library using CMake's FetchContent module, specifying the Git repository and tag. ```cmake FetchContent_Declare( saucer GIT_REPOSITORY https://github.com/saucer/saucer GIT_TAG v8.0.4 ) FetchContent_MakeAvailable(saucer) ``` -------------------------------- ### Handle Permission Requests Source: https://saucer.app/webview/events Subscribe to permission requests from web pages. The callback receives a request object that can be used to accept or deny the permission. If ignored, the request is denied by default. ```cpp webview->on([](const std::shared_ptr&) -> saucer::status { // ... }); ``` -------------------------------- ### Set Saucer Backend Source: https://saucer.app/getting-started/cmake Configures the backend to be used by Saucer. The default is platform-appropriate. ```cmake set(saucer_backend "Qt") ``` -------------------------------- ### Registering a Window Decoration Change Event Source: https://saucer.app/window/events Register a listener for changes in window decorations. The callback receives a decoration object. ```cpp window->on([](saucer::window::decoration) { // ... }); ``` -------------------------------- ### Handle Web Resource Request Event Source: https://saucer.app/webview/events Subscribe to events emitted when a web resource is requested by the web page. ```cpp webview->on([](const saucer::uri&) { // ... }); ``` -------------------------------- ### Register Custom Scheme Source: https://saucer.app/webview/schemes Register a custom URL scheme before creating any webview instances. This is a prerequisite for using custom schemes. ```cpp 1 int main() 2 { 3 saucer::webview::register_scheme("name"); 4 return saucer::application::create({.id = "hello-world"})->run(start); 5 } ``` -------------------------------- ### Registering a Window Maximize Event Source: https://saucer.app/window/events Register a listener for window maximize events. The callback receives a boolean indicating whether the window is maximized. ```cpp window->on([](bool) { // ... }); ``` -------------------------------- ### Handle DOM Ready Event Source: https://saucer.app/webview/events Subscribe to the event emitted when the Document Object Model (DOM) of a web page is ready. ```cpp webview->on([]() { // ... }); ``` -------------------------------- ### Registering an Event Source: https://saucer.app/window/events Register a listener for a specific window event. The `on` function takes an event type and a callback function. It returns an ID that can be used to unregister the event. ```APIDOC ## on(listener) ### Description Registers a listener function to be called when a specific event occurs. ### Method `on(listener)` ### Parameters - **event**: The type of the window event to listen for (e.g., `saucer::window::event::resize`). - **listener**: A callback function that will be executed when the event is triggered. The parameters of the listener depend on the specific event. ### Returns - **id**: A unique identifier for the registered event listener, used for unregistering. ``` -------------------------------- ### Set WebView2 Version Source: https://saucer.app/getting-started/cmake Specifies the version of the WebView2 NuGet-Package to be used. ```cmake set(saucer_webview2_version "1.0.2783-prerelease") ``` -------------------------------- ### Registering a Window Minimize Event Source: https://saucer.app/window/events Register a listener for window minimize events. The callback receives a boolean indicating whether the window is minimized. ```cpp window->on([](bool) { // ... }); ``` -------------------------------- ### Set Window Decorations Source: https://saucer.app/window/decorations Use this function to change the window's decoration type. Prefer 'partial' decorations when possible. ```cpp window->set_decorations(saucer::window::decoration::partial); ``` -------------------------------- ### Set Browser Flags for WKWebView Source: https://saucer.app/misc/portability Configure WKWebView with browser flags derived from WKWebViewConfiguration properties. Flags are passed as key-value pairs. ```cpp auto webview = saucer::webview::create({ .window = /*...*/, .browser_flags = {"upgradeKnownHostsToHTTPS=true", "defaultWebpagePreferences.allowsContentJavaScript=false", "preferences.minimumFontSize=10", "applicationNameForUserAgent=\"Saucer App\""}, }); ``` -------------------------------- ### Registering a Window Resize Event Source: https://saucer.app/window/events Register a listener for window resize events. The listener receives the new width and height. Returns an ID that can be used to unregister the event. ```cpp const auto id = window->on([](int width, int height) { // ... }); ``` -------------------------------- ### Registering a Window Close Policy Event Source: https://saucer.app/window/events Register a listener for the window close event, allowing control over the close operation. Subscribers can block or allow the close by returning a policy decision. ```cpp window->on([] -> saucer::policy { // ... }); ``` -------------------------------- ### Registering a Window Focus Event Source: https://saucer.app/window/events Register a listener for window focus events. The callback receives a boolean indicating whether the window gained focus. ```cpp window->on([](bool) { // ... }); ``` -------------------------------- ### Handle Favicon Loaded Event Source: https://saucer.app/webview/events Subscribe to events emitted when a website's favicon has been loaded. The loaded icon data is passed as a parameter, allowing inspection or saving. ```cpp webview->on([](const saucer::icon&) { // ... }); ``` -------------------------------- ### Handle Custom Scheme Requests Source: https://saucer.app/webview/schemes Register a handler for a specific webview instance to process requests sent to a custom scheme. The handler must return a saucer::scheme::response. ```cpp 1 webview->handle_scheme("name", [](const saucer::scheme::request& req) 2 { 3 return saucer::scheme::response{ 4 .data = saucer::stash::from_str(std::format("Hello: {}", req.url().string())), 5 .mime = "text/plain", 6 .status = 200, 8 }; 9 }); ``` -------------------------------- ### Using Embedded Files in Saucer Application Source: https://saucer.app/webview/embedding After linking against the `saucer::embedded` target, you can embed all available files into a webview and serve a specific HTML file. Calling `webview->embed` multiple times merges files. ```cpp #include #include coco::stray start(saucer::application *) { // ... webview->set_url("..."); webview->embed(saucer::embedded::all()); webview->serve("/index.html"); // ... } ``` -------------------------------- ### Handle Navigation Finished Event Source: https://saucer.app/webview/events Subscribe to the event emitted after a web page navigation has successfully completed. ```cpp webview->on([](const saucer::uri&) { // ... }); ``` -------------------------------- ### Awaiting an Event Source: https://saucer.app/window/events Asynchronously wait for a specific window event to occur. This is useful for scenarios like modals where you need to pause execution until an event is triggered with a specific outcome. ```APIDOC ## await(policy_decision) ### Description Asynchronously waits for a specific window event to occur. ### Method `co_await window->await(policy_decision)` ### Parameters - **event**: The type of the window event to await. - **policy_decision**: The policy decision to be passed to the event (e.g., `saucer::policy::allow`). ### Returns - **event_result**: The result or parameters typically returned by the event callback, but in this context, they are returned from the awaitable. The parameters usually passed to the event callback are passed as arguments to the await function. ``` -------------------------------- ### Handle Fullscreen Changes Source: https://saucer.app/webview/events Subscribe to fullscreen requests from web pages. The callback can return saucer::policy::block to prevent fullscreen or saucer::policy::allow to permit it. ```cpp webview->on([](bool fullscreened) -> saucer::policy { // ... }); ``` -------------------------------- ### Handle Division by Zero from JavaScript Source: https://saucer.app/webview/interop Demonstrates how a JavaScript call to an exposed C++ function that returns `std::expected` handles an error condition (division by zero). ```javascript > await saucer.exposed.divide(10, 0) ~~[Error]~~ Divisor must not be zero ``` -------------------------------- ### Registering a Window Closed Event Source: https://saucer.app/window/events Register a listener for when a window is closed. This event has no parameters. ```cpp window->on([] { // ... }); ``` -------------------------------- ### Add Saucer Package using CPM.cmake Source: https://saucer.app/getting-started Use this snippet to add the Saucer package to your project via CPM.cmake, specifying the name, version, and Git repository. ```cmake CPMAddPackage( NAME saucer VERSION 8.0.4 GIT_REPOSITORY "https://github.com/saucer/saucer" ) ``` -------------------------------- ### Registering an Event Once Source: https://saucer.app/window/events Register a listener that will be called only one time for a specific window event. Similar to `on`, but the listener is automatically removed after the first invocation. ```APIDOC ## once(callback) ### Description Registers a callback function to be executed only once when a specific event occurs. ### Method `once(callback)` ### Parameters - **event**: The type of the window event to listen for. - **callback**: The function to execute once when the event is triggered. ### Returns - **id**: A unique identifier for the registered event listener. ``` -------------------------------- ### Awaiting a Window Close Event Source: https://saucer.app/window/events Asynchronously await a window close event, allowing the program to pause until the event occurs and a policy is applied. The parameters and return values are inverted compared to standard event callbacks. ```cpp co_await window->await(saucer::policy::allow); // Window was closed. Do something useful... ``` -------------------------------- ### Manual Embedding File Generation via CMake Script Source: https://saucer.app/webview/embedding An alternative to `saucer_embed` is to manually invoke the `saucer-embed` CMake script from the command line, specifying the directory containing the web content. ```bash cmake -P /cmake/embed.cmake ``` -------------------------------- ### Decorated Event Source: https://saucer.app/window/events This event is emitted when a window's decorations change. ```APIDOC ## Event: decorated ### Description Emitted when a window's decorations change. ### Usage ```cpp window->on([](saucer::window::decoration) { // ... }); ``` ### Parameters - **decoration**: Information about the window's decorations. ``` -------------------------------- ### Resize Event Source: https://saucer.app/window/events This event is emitted when a window is resized. ```APIDOC ## Event: resize ### Description Emitted when a window is resized. ### Usage ```cpp window->on([](int, int) { // ... }); ``` ### Parameters - **width**: The new width of the window. - **height**: The new height of the window. ``` -------------------------------- ### Handle Title Change Event Source: https://saucer.app/webview/events Subscribe to events emitted when the title of a web page changes. The new title is provided as a string_view. ```cpp webview->on([](std::string_view) { // ... }); ``` -------------------------------- ### Handle JavaScript Exceptions in C++ Source: https://saucer.app/webview/interop Demonstrates how JavaScript exceptions thrown during `evaluate` calls are caught and returned as `std::expected` in C++. ```cpp > auto res = co_await webview->evaluate>("new Array(-1)"); > std::println("Error: {}", res.error()); ``` -------------------------------- ### Set Browser Flags for WebKitGtk Source: https://saucer.app/misc/portability Pass browser flags to WebKitGtk webviews using key-value pairs. Ensure flags are formatted correctly as 'property=value'. ```cpp auto webview = saucer::webview::create({ .window = /*...*/, .browser_flags = {"enable-javascript=false"}, }); ``` -------------------------------- ### Call Exposed C++ Function from JavaScript Source: https://saucer.app/webview/interop Demonstrates how to call an exposed C++ function from JavaScript using the `saucer.exposed` object. ```javascript const result = await saucer.exposed.multiply(5, 10); ``` -------------------------------- ### Using saucer::executor with Custom Error Types Source: https://saucer.app/webview/interop Shows how to use `saucer::executor` with a specific error type, in this case, `double`, for rejecting Promises. This allows for more structured error handling. ```cpp webview->expose("error", [](const saucer::executor& exec) { exec.reject(42); }); ``` -------------------------------- ### Link Saucer Library Source: https://saucer.app/getting-started Link the Saucer library to your project after it has been added or fetched. Ensure to replace [PRIVATE|PUBLIC] with the appropriate scope. ```cmake target_link_libraries(${PROJECT_NAME} [PRIVATE|PUBLIC] saucer::saucer) ``` -------------------------------- ### Access Native Member Source: https://saucer.app/misc/native Retrieve the native API object from a webview instance. This is the entry point for interacting with platform-specific features. ```cpp auto native = webview->native(); ``` -------------------------------- ### Set URL with Authority Source: https://saucer.app/webview/schemes Specify an authority for all custom scheme URLs to avoid issues with the JS-Fetch API on WebView2. The authority can be any string. ```cpp 1 smartview.set_url("demo://index.html"); 2 smartview.set_url("demo://root/index.html"); // "root" could be anything ``` -------------------------------- ### Link Private Target Source: https://saucer.app/misc/native Link against the `saucer::private` target to gain access to all required headers and libraries for the Native-API. ```cmake target_link_libraries(${PROJECT_NAME} [PRIVATE|PUBLIC] saucer::private) ``` -------------------------------- ### Handle Navigation Request Event Source: https://saucer.app/webview/events Subscribe to events emitted when a navigation is initiated or requested. The callback can return saucer::policy::block to prevent navigation or saucer::policy::allow to permit it. ```cpp webview->on([](const saucer::navigation&) -> saucer::policy { // ... }); ``` -------------------------------- ### Execute JavaScript and Capture Result Source: https://saucer.app/webview/interop Execute JavaScript code from C++ and capture the returned value. Supports basic expressions and function calls. ```cpp auto random = *co_await webview->evaluate("Math.random()"); auto pow = *co_await webview->evaluate("Math.pow({}, {})", 2, 5); ``` -------------------------------- ### Set Saucer Serializer Source: https://saucer.app/getting-started/cmake Defines the serializer for Saucer. Defaults to a glaze-based serializer. ```cmake set(saucer_serializer "Rflpp") ``` -------------------------------- ### Expose C++ Function to JavaScript Source: https://saucer.app/webview/interop Expose a C++ function to be callable from JavaScript. The function is registered with a given name and parameters. ```cpp webview->expose("multiply", [](double a, double b) { return a * b; }); ``` -------------------------------- ### Maximize Event Source: https://saucer.app/window/events This event is emitted when a window is maximized or unmaximized. ```APIDOC ## Event: maximize ### Description Emitted when a window is (un-)maximized. ### Usage ```cpp window->on([](bool) { // ... }); ``` ### Parameters - **is_maximized**: A boolean value, `true` if the window was maximized, `false` otherwise. ``` -------------------------------- ### Automated Web Content Embedding with CMake Source: https://saucer.app/webview/embedding Use the `saucer_embed` CMake function to automatically embed web content from a specified directory into your project. This function adds a pre-build hook to refresh embedded files. ```cmake include(FetchContent) FetchContent_Declare( saucer GIT_REPOSITORY "https://github.com/saucer/saucer" GIT_TAG $VERSION$ ) FetchContent_MakeAvailable(saucer) saucer_embed("out" TARGET ${PROJECT_NAME}) target_link_libraries(${PROJECT_NAME} PRIVATE saucer::saucer saucer::embedded) ``` -------------------------------- ### Minimize Event Source: https://saucer.app/window/events This event is emitted when a window is minimized or unminimized. ```APIDOC ## Event: minimize ### Description Emitted when a window is (un-)minimized. ### Usage ```cpp window->on([](bool) { // ... }); ``` ### Parameters - **is_minimized**: A boolean value, `true` if the window was minimized, `false` otherwise. ``` -------------------------------- ### Focus Event Source: https://saucer.app/window/events This event is emitted when a window gains or loses focus. ```APIDOC ## Event: focus ### Description Emitted when a window is (un-)focused. ### Usage ```cpp window->on([](bool) { // ... }); ``` ### Parameters - **is_focused**: A boolean value, `true` if the window gained focus, `false` otherwise. ``` -------------------------------- ### Registering a Non-Clearable Window Resize Event Source: https://saucer.app/window/events Register a window resize event listener that is marked as non-clearable. These events can only be unregistered by their specific ID. ```cpp window->on({{.func = [](int width, int height) { /*...*/ }, .clearable = false}}); ``` -------------------------------- ### Inject JavaScript Code Source: https://saucer.app/webview/scripts Injects a JavaScript code snippet into a web page. The script runs at creation time. A unique ID is returned for later management. ```cpp const auto id = webview->inject({ .code = "console.log('Hello from script!')", .run_at = saucer::script::time::creation, }); ``` -------------------------------- ### Manual Promise Resolution with saucer::executor Source: https://saucer.app/webview/interop Expose a function that manually handles a JavaScript Promise using `saucer::executor`. This is useful for performing operations and then resolving or rejecting the Promise based on conditions. ```cpp webview->expose("divide", [](double a, double b, const saucer::executor& exec) { const auto& [resolve, reject] = exec; if (b == 0) { return reject("Divisor must not be zero"); } return resolve(a / b); }); ``` -------------------------------- ### Expose C++ Function Returning std::expected Source: https://saucer.app/webview/interop Expose a C++ function that returns `std::expected` to signal success or failure with an error message to JavaScript. ```cpp webview->expose("divide", [](double a, double b) -> std::expected { if (b == 0) { return std::unexpected{"Divisor must not be zero"}; } return a / b; }); ``` -------------------------------- ### Controlling Promise Lifetime with saucer::executor Source: https://saucer.app/webview/interop Demonstrates how to control the lifetime of a JavaScript Promise by resolving it asynchronously on a separate thread. This allows for operations that take time to complete before the Promise is settled. ```cpp webview->expose("wait", [](saucer::executor exec) { std::thread t{[exec = std::move(exec)] { std::this_thread::sleep_for(std::chrono::seconds(5)); exec.resolve(42); }}; t.detach(); }); ``` -------------------------------- ### Close Event Source: https://saucer.app/window/events This event is emitted just before a window is closed, allowing subscribers to block or allow the close operation. ```APIDOC ## Event: close ### Description Emitted when a window is about to be closed. Subscribers can influence the close operation. ### Usage ```cpp window->on([] -> saucer::policy { // ... return saucer::policy::allow; // or saucer::policy::block }); ``` ### Returns - **policy**: A `saucer::policy` value, either `saucer::policy::block` to prevent closing or `saucer::policy::allow` to permit closing. ``` -------------------------------- ### Handle RPC Message Event Source: https://saucer.app/webview/events Subscribe to events emitted when an RPC message is sent. Return saucer::status::handled if the message was processed, or saucer::status::unhandled to allow other subscribers to process it. ```cpp webview->on([](std::string_view) -> saucer::status { // ... }); ``` -------------------------------- ### Expose C++ Function Throwing Exception Source: https://saucer.app/webview/interop Expose a C++ function that throws a `std::runtime_error` when a specific condition is met, allowing JavaScript to handle the error. ```cpp webview->expose("divide", [](double a, double b) { if (b == 0) { throw std::runtime_error{"Divisor must not be zero"}; } return a / b; }); ``` -------------------------------- ### Registering a Non-Clearable Event Source: https://saucer.app/window/events Register an event listener that will not be automatically cleared by wildcard disconnects. These events must be explicitly disconnected using their ID. ```APIDOC ## on({{.func = listener, .clearable = false}}) ### Description Registers a listener for a specific event that is marked as not clearable by wildcard operations. ### Method `on({{.func = listener, .clearable = false}})` ### Parameters - **event**: The type of the window event. - **listener**: The callback function to execute. - **clearable**: A boolean flag, set to `false`, indicating this event should not be cleared by `off(event)`. ### Returns - **id**: A unique identifier for the registered event listener. ``` -------------------------------- ### Enable MSVC Mutex Hack Source: https://saucer.app/getting-started/cmake Enables a workaround for issues caused by constexpr mutex constructors in MSVC version 17.10, particularly affecting Java Bindings. ```cmake set(saucer_msvc_hack ON) ``` -------------------------------- ### Execute JavaScript Without Capturing Result Source: https://saucer.app/webview/interop Use `execute` to run JavaScript code when the return value is not needed. This is more efficient than `evaluate` in such cases. ```cpp webview->execute("console.log({})", saucer::make_args(1, "Test", std::vector{4, 2})); ``` -------------------------------- ### Clear All Clearable Injected Scripts Source: https://saucer.app/webview/scripts Removes all injected scripts that are marked as 'clearable'. This is a convenient way to reset all user-injectable scripts. ```cpp webview->uninject(); ``` -------------------------------- ### Closed Event Source: https://saucer.app/window/events This event is emitted when a window is closed. ```APIDOC ## Event: closed ### Description Emitted when a window is closed. ### Usage ```cpp window->on([] { // ... }); ``` ``` -------------------------------- ### Expose C++ Coroutine Returning std::expected Source: https://saucer.app/webview/interop Expose a C++ coroutine function that returns `std::expected` to handle asynchronous operations and potential errors gracefully. ```cpp webview->expose("divide", [](double a, double b) -> coco::task> { if (b == 0) { co_return std::unexpected{"Divisor must not be zero"}; } co_return a / b; }); ``` -------------------------------- ### Disable MacOS Private API Source: https://saucer.app/getting-started/cmake Controls the usage of private MacOS APIs. Disabled by default, disabling has several consequences for security and API availability. ```cmake set(saucer_private_webkit OFF) ``` -------------------------------- ### Define Exposed Function with TypeScript Source: https://saucer.app/webview/interop Define the signature of an exposed C++ function when using the TypeScript package for type safety. ```typescript import { exposed } from "@saucer-dev/types"; const multiply = exposed("multiply"); ``` -------------------------------- ### Pass Unquoted String to JavaScript Execute Source: https://saucer.app/webview/interop Use `saucer::unquoted` to pass strings to JavaScript execution without them being automatically quoted, useful for passing code snippets or identifiers. ```cpp webview->execute("{}({})", saucer::unquoted{"console.log"}, "42"); ``` -------------------------------- ### Unregistering a Specific Window Event Source: https://saucer.app/window/events Unregister a specific event listener using its ID. This is used to stop listening to a particular event. ```cpp window->off(saucer::window::event::resize, id); ``` -------------------------------- ### Remove Injected Script Source: https://saucer.app/webview/scripts Removes a previously injected script using its unique ID. This allows for targeted removal of scripts. ```cpp webview->uninject(id); ``` -------------------------------- ### Unregistering All Events of a Specific Type Source: https://saucer.app/window/events Unregister all event listeners of a specific event type by omitting the event ID. This is useful for cleaning up all listeners for a particular event. ```cpp window->off(saucer::window::event::resize); ``` -------------------------------- ### Disable Saucer Exceptions Source: https://saucer.app/getting-started/cmake Explicitly disables Saucer's exception catching mechanism for exposed functions. This is relevant when compiled without `-fno-exceptions`. ```cmake set(saucer_exceptions OFF) ``` -------------------------------- ### Unregistering an Event Source: https://saucer.app/window/events Remove an event listener using its unique ID or by event type. You can remove a specific listener by providing both the event type and its ID, or remove all listeners for a given event type. ```APIDOC ## off(event, id) ### Description Removes a specific event listener. ### Method `off(event, id)` ### Parameters - **event**: The type of the window event. - **id**: The unique identifier of the listener to remove. ## off(event) ### Description Removes all event listeners for a specific event type. ### Method `off(event)` ### Parameters - **event**: The type of the window event for which to remove all listeners. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.