Script widgets questions

Håkan Liljegren hakan at
Tue May 2 11:47:33 EDT 2023

Dabbling with some script widgets. Fun, but a bit tedious at the moment, but here are some findings and some questions/proposals. 

=== Findings: (Can be me missing something though…) ===

Don’t forget that you need to click the “Show Options” button in the file chooser and change the Format to “LiveCode Script” to be able to load your script widget at all in the Extension Builder. (I missed this and got very frustrated before I realised this) Often after changing the Format to “LiveCode Script” the script file is still greyed out, but you can still double-click the file to load… Unfortunately you need to set the format every time the file chooser pops up…

When creating a script widget you should use the extension builder to test it. Opening the script file, editing and saving and then creating via the command line via “create widget as …” is a bit hit and miss for me. It might be that I need to set things up better but even when trying the tutorials from the mothership it doesn’t work as expected. But opening the “Extension Builder” and then testing the widget works!

It is at the moment really easy to crash LiveCode when testing a widget. It feels like if you have almost any error in the code you might crash LiveCode, so count on that you need to save all the time and be prepared to restart often! This will certainly (hopefully?) improve as this is an early pre-release of script widgets.

When you are done testing, just close the window and LiveCode will handle everything for you or click the “Stop testing extension” button in the Extension Builder. If you use “Close and remove from memory” your test might not end properly and you might just get “Your widget is up to date” the next time you try to test it.

It is fine to “overload” properties in the widget. E.g. having a property named “backgroundColor” Is fine and your get- and setProp will be called. If you don’t add the "get propertyMetadata” for a property LiveCode will still add an entry in the inspector. This is both good and bad. Good because you can test your widget early, and bad because there seems to be no way to NOT get the property to show up. One strange finding here is that I created a “field” widget with some extra bells and whistles. So therefore I added properties for text, rtfText and htmlText. Of these I only wanted to show the text in the inspector. The htmlText and the rtfText shows up whatever I try but the text does not!? I can set the text fine via code though…

=== Questions / Proposals (Can again be me not knowing/missing something…) ===

It would be nice to be able to add properties that NOT show up in the inspector. My suggestion is that if there is a getProp propertyMetadata function only the properties included there should be included in the inspector.

When adding properties there seems to be no way to control the order they show up in the inspector!? Or is it? This makes it hard to get any logical order of the properties. This could be solved with an “order” key for each entry in propertyMetadata like:
getProp propertyMetadata[pProperty]
   switch pProperty
      case “backgroundColor"
          return {
		“order”: 1

It would also be nice to able to write:

getProp propertyMetadata[pProperty]
   switch pProperty
      case “backgroundColor"
          return {
		“type”: “native”

Or some other way to support the “native” properties. A standard group in LiveCode can have colors, effects, and text settings and the colors and text settings are inherited by the controls in the group unless they have their own properties and effects are applied to the group. When creating script widgets you then need to duplicate all of this if you want to support it, and that shouldn’t be needed (IMHO). If it would be possible to just enable a tab in the inspector it would be really nice like:
getProp inspectorTabs[pTab]
	switch pTab
		case “colors”:
			return true
		case “effects”
			return false

Or something similar to enable or disable a full tab.

But my final say is, that even if the script widgets are in an early stage, they are a really important and nice addition! So, keep up the good work!


More information about the use-livecode mailing list