@@ -459,11 +459,28 @@ namespace webui {
459459 webui_set_context (webui_window, element.data (), context);
460460 }
461461
462- // Gets Win32 window `HWND`. More reliable with WebView than web browser
462+ // Gets Win32 window `HWND`. More reliable with WebView than web browser
463463 // window, as browser PIDs may change on launch.
464464 void * win32_get_hwnd () const {
465465 return webui_win32_get_hwnd (webui_window);
466466 }
467+
468+ // Get the native window handle. On Windows returns HWND (works with WebView
469+ // and web browser). On Linux returns GtkWindow* (WebView only).
470+ void * get_hwnd () const {
471+ return webui_get_hwnd (webui_window);
472+ }
473+
474+ // Bring the window to the front and give it keyboard focus.
475+ void focus () const {
476+ webui_focus (webui_window);
477+ }
478+
479+ // Set a callback to intercept the close event of a WebView window.
480+ // The handler must return false to prevent closing, true to allow it.
481+ void set_close_handler_wv (bool (*close_handler)(size_t window)) const {
482+ webui_set_close_handler_wv (webui_window, close_handler);
483+ }
467484 };
468485
469486 // ------ Namespace members `webui::xxx()` ------
@@ -575,6 +592,28 @@ namespace webui {
575592 webui_memcpy (dest, const_cast <void *>(src), count);
576593 }
577594
595+ // Wait asynchronously until all opened windows get closed.
596+ // Returns true if more windows are still open, false when all are closed.
597+ // Must be called from the main thread in WebView mode.
598+ inline bool wait_async () {
599+ return webui_wait_async ();
600+ }
601+
602+ // Set a custom logger function to receive WebUI's internal log messages.
603+ inline void set_logger (void (*func)(size_t level, const char * log, void * user_data), void* user_data = nullptr) {
604+ webui_set_logger (func, user_data);
605+ }
606+
607+ // Get the error code from the most recent WebUI operation that failed.
608+ inline size_t get_last_error_number () {
609+ return webui_get_last_error_number ();
610+ }
611+
612+ // Get the human-readable error message from the most recent failed WebUI operation.
613+ inline std::string_view get_last_error_message () {
614+ return std::string_view{webui_get_last_error_message ()};
615+ }
616+
578617} // namespace webui
579618
580619#endif /* _WEBUI_HPP */
0 commit comments