dunbarx wrote: ↑Sat Oct 08, 2022 6:49 pm
Anyway, how would you quickly describe the advantages of widgets? I thought the whole point was that they could reach into places LCS could not...
LCB offers two salient features: the ability to make custom controls that are more easily shareable than what we could make with groups, and a foreign function interface (FFI) for accessing OS routines and other binary APIs.
Those can be used together, but not necessarily. For example, I can't imagine the Clock widget needs low-level access to the OS, whereas I believe the button widgets use OS calls for rendering native appearance.
LC Script offers a wide range of great primitives, like fields, buttons, scrollbars, images, graphics, etc., which we often use to make custom controls. The DataGrid is a famous example of a complex one, but many of us use grouped controls driven by a central behavior script for all sorts of things.
One of the best things about using LC Script for custom controls is the field object. It's extremely powerful, and I don't believe LCB offers anything like it (I'm not sure LCB offers an editable text object at all; earlier versions didn't).
The only downside to using grouped controls to make a custom control is sharing it across projects. You'll need some way for the behavior script to come along for the ride, and an easy way to instantiate the custom control.
Within my own projects a simple copy command instantiates easily enough, and since I work in small teams it's easy to remind others using it to also include the behavior that drives it.
But for sharing with other LC devs we want to aim higher, to make them much easier to install and use.
And that's where the packager comes in. If the various parts needed for sharing a custom control can be put into a single file, and the packager system understands the layout of the file and can put things where they need to go, sharing becomes much easier. And with the dynamic spec-driven layout of the Inspector, one can even have custom settings there for the properties unique to the new control type.
What's not clear to me is the other part, FFI. There are several challenges with adding that to LiveCode Script, much of it being the need for specific data types, problematic in a typeless scripting language.
Toolbook solved it by having optional type declarations that were very flexible, sufficiently that one could declare the type and that they were calling foreign functions, and the Toolbook engine took care of the rest. I used it on a project once and it was pretty cool, allowing be to use Win APIs to bind one window as an overlay region in another.
A widgets packager for LC Script would be pretty awesome in itself.
But if they're also in a position to extend LC Script to be able to call foreign functions, that would be mind-blowingly cool.