webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.9k stars 164 forks source link

`set_default_root_folder` doesn't set the path for windows that were created after calling the function #178

Closed ttytm closed 1 year ago

ttytm commented 1 year ago

Thanks for implementing the new function.

Currently the function needs to be called after the webui_new_window functions were called. If calling it prior to creating the windows the path is not set.

E.g.

const (
    w  = ui.Window(1)
    w2 = ui.Window(2)
)

fn main() {
    // ui.set_root_folder(@VMODROOT) // Won't work
    w.new_window()
    w.bind('SwitchToSecondPage', switch_to_second_page)
    w.bind('OpenNewWindow', show_second_window)
    w.bind('Exit', exit_app)
    w.bind('', events)
    w.show('index.html')

    w2.new_window()
    w2.bind('Exit', exit_app)

    ui.set_root_folder(@VMODROOT) // Works
    ui.wait()
}
hassandraga commented 1 year ago

Yes, I forgot to update webui_new_window_id(). But in general ui.set_root_folder() should be before .show().