sciter-sdk / go-sciter

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

Would someone show an example of custom behavior? #81

Open taonylu opened 6 years ago

taonylu commented 6 years ago

I'm sorry for ask an example. I don't know how to make an custom behavior in go lang. If you could give an simple example, I would be very happy. Thank you.

pravic commented 6 years ago

Basic principles are described in this article about native behaviors in Sciter. Also there is an article in Sciter's Help browser, check its last section called "Custom Components".

The list of standard behaviors: https://sciter.com/developers/sciter-docs/native-behaviors/

Basically you can create custom behavior either in script or in native side by attaching an own handler to particular existing or created html element. This handler is called for each created element (see Element.attached function in script or sciter::event_handler::attached in C++ or sciter.EventHandler.OnAttached in Go), so you can subscribe to its events, create additional HTML elements inside it and do whatever you want.

Custom behaviors usually created in script because it is much easier to do. There are a lot of examples in sciter samples (see custom-inputs, graphics, ideas folders). As for native behaviors, they are used to interact with OS services like USB camera, native components and drawing (native child windows, opengl/directx panels, video and so on).

So, I am not sure what kind of native behavior you would like to have in Go. It is easy to make, but I have no idea, what it should do.

taonylu commented 6 years ago

Thank you for your answer. I am going to add an embed webbrowser, such as miniblink( you could find it in github). In past, when I use htmllayout, I can create a static or custom control to attach an custom behavior, to load html page. Thank you for your help. I'll try this OnAttached callback. I am new to this go-sciter sdk.

^.~

pravic commented 6 years ago

Native API in Sciter was not so changed since HTMLayout, so it wouldn't be a problem. Web browser is basically a child window, the first article I mentioned explains it well.

ibenben commented 5 years ago

Basic principles are described in this article about native behaviors in Sciter. Also there is an article in Sciter's Help browser, check its last section called "Custom Components".

The list of standard behaviors: https://sciter.com/developers/sciter-docs/native-behaviors/

Basically you can create custom behavior either in script or in native side by attaching an own handler to particular existing or created html element. This handler is called for each created element (see Element.attached function in script or sciter::event_handler::attached in C++ or sciter.EventHandler.OnAttached in Go), so you can subscribe to its events, create additional HTML elements inside it and do whatever you want.

Custom behaviors usually created in script because it is much easier to do. There are a lot of examples in sciter samples (see custom-inputs, graphics, ideas folders). As for native behaviors, they are used to interact with OS services like USB camera, native components and drawing (native child windows, opengl/directx panels, video and so on).

So, I am not sure what kind of native behavior you would like to have in Go. It is easy to make, but I have no idea, what it should do.

Would you show an example of USB camera?

taonylu commented 5 years ago

Thank you for your answer. I've already road those articles. But this is in Golang, the behavior was not found an example in this porting. I've tried some methods, only get one not good method: Find the element, then do event binding and editting attributes. I am still finding such behavior example like C lang. To embed an webbrowser in application.

Kindly regards, Taony