feat: expose get_best_browser to C and C++ api

This commit is contained in:
SpikeHD 2024-02-13 00:07:53 -08:00
parent 2a5f0c98fb
commit a4168b9b19
3 changed files with 21 additions and 0 deletions

View File

@ -192,6 +192,19 @@ WEBUI_EXPORT size_t webui_get_new_window_id(void);
*/
WEBUI_EXPORT size_t webui_bind(size_t window, const char* element, void (*func)(webui_event_t* e));
/**
* @brief Get the "best" browser to be used. If running "webui::show()"
* or passing AnyBrowser to "webui::show_browser()", this function will
* return the same browser that will be used.
*
* @param window The window number
*
* @return Returns the best browser to be used.
*
* @example size_t browser = webui_get_best_browser(myWindow);
*/
WEBUI_EXPORT size_t webui_get_best_browser(size_t window);
/**
* @brief Show a window using embedded HTML, or a file. If the window is already
* open, it will be refreshed.

View File

@ -181,6 +181,8 @@ class window {
// Get the ID of the last child process spawned by the browser.
size_t get_child_process_id() const { return webui_get_child_process_id(webui_window); }
size_t get_best_browser() const { return webui_get_best_browser(webui_window); }
// Set the web-server root folder path for this specific window.
bool set_root_folder(const std::string_view path) const {
return webui_set_root_folder(webui_window, path.data());

View File

@ -1167,6 +1167,12 @@ size_t webui_bind(size_t window, const char* element, void( * func)(webui_event_
return cb_index;
}
size_t webui_get_best_browser(size_t window) {
// This just exposes the existing function
_webui_window_t * win = _webui_core.wins[window];
return _webui_find_the_best_browser(win);
}
const char* webui_get_string_at(webui_event_t* e, size_t index) {
#ifdef WEBUI_LOG