macMikey / LCB-missing-manual

I'm trying to learn LCB, again, but the docs are thin.
MIT License
4 stars 4 forks source link

Libraries vs Widgets #53

Open mwieder opened 1 year ago

mwieder commented 1 year ago

Not sure where to put this, but I think it's important in understanding LCB:

There are two types of extensions: libraries and widgets. The two have almost no points in common. Library extensions are for importing into other extensions with the "use" command. This is normally done in widget code, but if necessary a library can consume another library. I've never seen this in the wild, but it seems possible. If you "use" a library then its handlers are available to the encompassing script, much in the same way as frontscripts, backscripts, library scripts, and behaviors. Libraries can not be referenced by name, id, etc, so they can not have properties. Only widgets have properties that are accessible externally and via the Property Inspector. Widgets are self-contained, so you can not call their handlers from outside the widget. You can only externally call handlers contained in a library. Thus the onSave handler in a widget is only invoked on a save event... you can't send an "onSave" or "save" message to a widget. Dispatching a handler to a widget results in it being "unhandled". There appears to be a limited number of canned events to create handlers for, and it's unclear whether more event handlers can be added.

macMikey commented 1 year ago

Well, we have a wiki page on libraries, but i don't have a page on widgets, yet. thoughts?

mwieder commented 1 year ago

That bug report is very interesting. I think it implies that the act of compiling an LCB script makes it compatible at a bytecode level with a compiled LCS script. And I need to brain that a bit before I can figure out what that means.

mwieder commented 1 year ago

There are also references to things like OnClose handlers, and I don't know if there is a limited set of possible event handlers and it's just undocumented, or if you can make new ones for internal messages.

mwieder commented 1 year ago

...and (yet more) the foreign handlers interface can use several builtin types (Boolean, String, etc) but the examples use things like CBool and CUInt, but they aren't documented anywhere. I could (and do) assume that Boolean = CBool but I'd also like a double type and a Point type. I tried using a CUInt32 type but it doesn't exist. Would be nice to have documentation, especially since these are used in the User Guide. And there's a Pointer type, but it's just generic - you can't point it to anything specific.

macMikey commented 1 year ago

Welcome to the project. sigh.