tperry2x wrote: ↑Wed Aug 14, 2024 7:07 pm
I noticed it made all manner of other files:
piles-of-files.png
OK, this is probably stuff that should go in a 'How-To-Build-Widget Extensions' and/or a 'What Are Widgets anyway' section, but I'll try to go through this here.
The 'All manner of other files' are files that Extension Builder created from data extracted from the .LCB file, they are used by the IDE, Dictionary (API.lcdoc) and Extension Management (manifest and 'interface' file). Some of these can also be created manually/separately like if you didn't want to use the inline documentation system in your code you can make that markdown file from scratch. Extension Project can also have additional folders with things like foreign code libraries, LoDPI/HiDPI icon images, or any other resource your Extension may need to include. The most important file that gets generated is actual compiled module bytecode which ends in ".lcm" (LC Module), there is syntax that can load that module from disk file. When you 'Package Extension" all of these files get zipped up into a file that ends with ".lce" (LC Extension). That's the package system used to deliver new Extensions to IDE users.
At first I thought it hadn't worked, but it is there:
fool-1.png
Note: the label text font was "" and the label text size was 0.
As soon as I set that to a font (Liberation Sans) and 12 under the label text size, it worked and I could change the other properties through the inspector, just as you would a 'classic control'.
fool-2.png
So, all good.
Well not so much 'good' as it is a work-in-progress. It's odd that setting the 'label property did anything for you, it should've only worked with 'set the
text of Widget ..." to whatever, 'the label' shouldn't be stored the same as or used as an synonym for 'the text' prop, in the same way a button menu can have a 'the text' list property
AND separately a button 'label' prop ). Anyway it should have had the default text filled in by the OnCreate handler so I'll have to look at that.
But, here's where I come back to my question a little further up. When trying to save the stack, I can't. It goes through the motions of saving a stack - but the stack file never appears. I don't get an error or anything either, which means I lose any changes to this new stack, and have to repeat the entire process through 'Extensions Builder' again.
I had hoped it would be a simple oxtstack file that you could copy & paste the 'LabelBox' out of and into a stack of your choice, but it doesn't work like that
Also, I wondered - do these files then need to all live in a subfolder together somewhere? Sorry for all the foolish questions.
What gets stored in the stack file is only reference to the extension module used, and the properties array that was used with it. So if the Extension is not loaded by the Engine FIRST, you won't see any widget when you open that stack. If the Extension is installed (instead of temporarily loaded) either in the User Folder or included in the IDE folders, then it gets automatically loaded when the Engine starts up. If you're only
TESTING the Extension but did not
install it, then the module gets auto-unloaded when you close that temporary test stack it that it created, so if you then open a saved stack again that had it place on to the card, then the Widget module won't be loaded and you'll get no Widget on screen. The temporary testing stack that it creates should not (cannot?) be saved, don't do that, instead install the widget, then place it on a card in a new stack, save that stack, then reopen the widget should be there as long as the module is still loaded.
If you change widget identifier, or the editable properties of, or version number, and then load this newer version of the same widget, and the properties array in a stored in a previously mad stack may not 'match-up' and you may again get no widget displayed when you open that stack where the widget reference to the old version of it was placed. You may get some message about an 'Array Element' is missing or something like that, which is the array that widgets properties are stored in.
Now, that
is sort of an issue with Widgets, they need to be loaded into memory before they can be used, they are not
normally stored embedded in their entirety into the stack file, but an interesting trick is that they can be loaded from binarydata of that module.lcm file, so you can store that data, in a variable or perhaps in a custom property embedded into a stack file, and then you load the module from that data 'on preOpenStack' before the Widget is needed in order to render anything. I've even done this in 'script only ' stack by base64 encoding the binary module and storing it as plain ASCII text in a variable, easy/fast decode+load.
If we all had the same base set of Widgets (which we should already have the same very basic set of including the IDE Widgets and the SVGPath Icon widget) then it's not a problem to use any of those widgets without needing to also include the Widget along with the stack (although I would still prefer be able to
optionally encapsulate it all together), but not the case if it's a brand new custom widget that you want to share a demo stack of. This was the spark for the idea I've mentioned a few times for having something like the old HC 'Resource Movers' and a pseudo 'Resource Fork' that can be used to embed Extensions into a stack and inject a small preOpenStack Script script to load them.
Hope that helps make some sense of it.