sciter-sdk / go-sciter

Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development
https://sciter.com
2.57k stars 268 forks source link

[HELP] is there a way to open a file selector dialog? #331

Closed Hyppothalamus closed 2 years ago

Hyppothalamus commented 2 years ago

Like the title is saying is there a way to open a file dialog?

i have found some examples but can't figure out how to use them. any help is always welcome. :)

pravic commented 2 years ago

To open from Go or from the script?

Hyppothalamus commented 2 years ago

at the moment i am trying to open it from the script. but if i can also open it in go, I am also happy

Hyppothalamus commented 2 years ago

what I have atm: html

<html>
    <style>
    </style>
    <script>
    </script>
    <body>       

        <h1>installer</h1>
        <button id="selectFolder">Click Me</button>
        <script type="text/tiscript">

            $(button#selectFolder).onClick = function(){
                var d = view.selectFolder("/home/kasper", "/home/kasper");
                view.msgbox(d);
            }

        </script>

    </body>
</html>

go

package main

import (
    "github.com/sciter-sdk/go-sciter"
    "github.com/sciter-sdk/go-sciter/window"
)

func main() {
    // make rect for window
    rect := sciter.NewRect(100, 100, 300, 500)

    // create a window using upper rect
    sciter.SetOption(sciter.SCITER_SET_SCRIPT_RUNTIME_FEATURES, sciter.ALLOW_SOCKET_IO)
    sciter.SetOption(sciter.ALLOW_FILE_IO, 1)
    sciter.SetOption(sciter.ALLOW_SYSINFO, 1)
    win, _ := window.New(sciter.SW_TITLEBAR|sciter.SW_MAIN|sciter.SW_CONTROLS|sciter.SW_ENABLE_DEBUG, rect)
    win.LoadFile("./main.html")
    win.SetTitle("Kloterij")

    win.Show()
    win.Run()
}

if this can help also on arch linux x86

pravic commented 2 years ago

No, it's possible only from script.

JS: https://github.com/c-smile/sciter-js-sdk/blob/main/docs/md/Window.md#windowselectfileparams TIS: https://github.com/c-smile/sciter-sdk/blob/master/doc/content/sciter/View.htm#L121

at the moment i am trying to open it from the script. but if i can also open it in go, I am also happy

pravic commented 2 years ago

sciter.SetOption(sciter.SCITER_SET_SCRIPT_RUNTIME_FEATURES, sciter.ALLOW_SOCKET_IO) sciter.SetOption(sciter.ALLOW_FILE_IO, 1) sciter.SetOption(sciter.ALLOW_SYSINFO, 1)

This should be

sciter.SetOption(sciter.SCITER_SET_SCRIPT_RUNTIME_FEATURES, sciter.ALLOW_SYSINFO|sciter.ALLOW_FILE_IO)
Hyppothalamus commented 2 years ago

thank you very much! it worked!