sciter-sdk / go-sciter

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

Connecting to inspector and writing to the console doesn't work #70

Closed dandevelo closed 7 years ago

dandevelo commented 7 years ago

This is the html I'm testing with simple.go

<div>
    <button id="insp">Inspector</button>
    <button id="btn">Click Me</button>
</div>
<script type="text/tiscript">

$(#btn).on("click",function(){
    stdout.printf("Clicked the button\n");
});

$(#insp).on("click", function() {
    stdout.printf("Connecting to inspector\n");
    if( var connectToInspector = view.connectToInspector ) {
        connectToInspector();
        stdout.printf("Connected to inspector\n");
   }
});

</script>

When I click the Inspector button it seems like it is connecting but when clicking the other button - the one with the stdout.printf("Clicked the button"\n), nothing is written in the inspector console.

The html runs without any issues in Sciter.app. It only has issues in the Go app.

This is on macOS.

pravic commented 7 years ago

You have to enable debug mode first, as I remember.

dandevelo commented 7 years ago

You're right. Got this from handlers.go.

ok := w.SetOption(sciter.SCITER_SET_DEBUG_MODE, 1)
if !ok {
    log.Println("set debug mode failed")
}

It works now! Thanks a lot!