How to get the properties defined in a Widget Extension

Organizing tasks to work on, New Features Ideas, Building LCS & LCB Libraries & Widgets, Redecorating and Modifying the IDE, Hacking / Editing Tools, Compiling the Engine from Source, etc.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: How to get the properties defined in a Widget Extension

Post by OpenXTalkPaul »

HEY! Just had a play with this one, this is probably the best IDE handler to use to build an Widget Inspector from:

Code: Select all

put true into tOrganize
put revIDEExtensionPropertiesInfo( "com.livecode.widget.treeview", tOrganize) into tArray
Given an extension 'kind' ID revIDEExtensionPropertiesInfo returns and array of ALL of the properties for that kind, and includes the elements with the details about each property such as the editor to use, value range, etc.

if that 'tOrganize' parameter is true, then it makes the top level of the returned array be the inspector section (basic, color, text, etc.),if any, that the property should be displayed in, with the 2nd level of array being a single element ["grouplist"] which is an array/list of the properties that should go in that section.

The Tree View Widget is sooooo incredibly useful for looking at array structure, I don't why it took me so long to start using it! I'm using it constantly now. Most of the IDE uses arrays to store its infos.
Try setting its arrayData to the revPrefs props:

Code: Select all

set the arrayData of widget "Tree View" to the customProperties of stack "revPreferences"
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: How to get the properties defined in a Widget Extension

Post by OpenXTalkPaul »

So foldState is a property that's used in a few of the LC provided Widgets included in the IDE.
And... I was wrong! It is NOT a boolean it's an Array.

I found that out because to tie this all together in the way you wanted, I rebuilt the widget parsing stack you posted with scripts that use the existing IDE Extensions functions:
widgetDataTests-v3-Paul.oxtstack
(15.29 KiB) Downloaded 137 times
Click an item listed in each list field to drill down to more info about each property's properties.
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: How to get the properties defined in a Widget Extension

Post by tperry2x »

Hahaha, I find this hilarious. We were both working on the exact same thing. :D
widgetDataTests-v3.png
widgetDataTests-v3.png (108.14 KiB) Viewed 4436 times
Attachments
widgetDataTests-v3.oxtstack
(18.13 KiB) Downloaded 139 times
User avatar
tperry2x
Posts: 3210
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: How to get the properties defined in a Widget Extension

Post by tperry2x »

I think I prefer your one because It's a little cleaner, and I probably don't need that Manifest info (?)

Both your stack and mine suffer from the same problem with the treeview widget though. You can see I've hilited the switchbutton widget > theme > options - but in the treeview widget, it shows "native..." on both of our stacks.

Is there a way to see the entire options here as either multiple lines or as a comma separated single line?
widgetDataTests-v3-Paul.png
widgetDataTests-v3-Paul.png (64.66 KiB) Viewed 4436 times
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: How to get the properties defined in a Widget Extension

Post by OpenXTalkPaul »

tperry2x wrote: Thu May 16, 2024 6:14 pm Hahaha, I find this hilarious. We were both working on the exact same thing. :D

widgetDataTests-v3.png
👍 Yes it's unusual, but I think we're overdue for this sort of collaboration.
While It's still true that I have less time to actually write/test code for the IDE, I do have some time that I can spend on researching these things because I can do that from virtually anywhere really, so this is sort of a way that I can still work on OXT IDE without actually working on OXT...

That Tree Widget isn't really relevant or used by my scripts. I just put the widgets() that there so that I could view the full Widgets() array, so that I could see the structure while writing the scripts.

I've only recently started using the 'Tree View' widget a lot more, and I've mostly used it as a quick way to inspect structure of Arrays, however, a quick look at it's docs and lcb source shows:

Code: Select all

get the hilitedElement of widget "Array Viewer"-- it =  a comma delimited list of array keys ''path' such as "key1,subkey2,subsubkey5"
Which you could then use to get the actual value of the highlighted element of the array and then display it in some way.
I can't see any direct method to get the selected element's value in a more direct way as there could be (but adding one is another sub-project I suppose).

The Tree View widget generates a few messages your scripts can respond to, probably you want to use hiliteChanged:
The <hiliteChanged> message is sent to the widget's script object when a row of the
widget's display is clicked on, causing that row to be highlighted. Use the <hilitedElement>
property to fetch the row's associated array keys.
Or maybe actionInspect message, sent when the 'inspect' icon is clicked when in read only mode.

Code: Select all

on actionInspect pElementPath
  put pElementPath -- should put something like "theme,options"
  put the arrayData of me into tArray
  put tArray[item 1 of pElementPath][item 2 of pElementPath] -- would get the value for tArray["theme"]["options"] 
end actionInspect
A bit convoluted but that should work to get those values

It seems the display is calculated to some degree based on width available to draw the text into, not sure why those values are truncated even when there's lots of space available (again, fixing that would be another sub-project).
There is a few properties such as 'readOnly' and 'arrayStyle' that effect the way the arrayData is displayed.
I do see there's a property (charsToTrimFromKey) to remove leading characters from the display of the element key name, but not to remove trailing characters, nor is there a property to set a minimal amount of characters to display.

"Tree View" is the same widget that's used as an editor for arrays in rev Props Inspector.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: How to get the properties defined in a Widget Extension

Post by OpenXTalkPaul »

I may have mentioned this one before, but while adding in-line docs fro IDE libraries I came across this again...
There's a whole palette that's included in the IDE that is not being used anywhere in the IDE as far I can tell,
a Snippet Viewer, and there's a handler to invoke it that takes a path to a text (utf8) file to display in the palette.
Like so:

Code: Select all

revIDEExtensionShowSnippet "/Users/Paul/Text.txt"
It sort-of works I guess, but the palette is like not even beta quality, its like unfinished quality.
Screen Shot 2024-05-17 at 1.30.28 AM.png
Screen Shot 2024-05-17 at 1.30.28 AM.png (38.79 KiB) Viewed 4411 times
I think the idea behind this was some sort of scripter's scrapbook kind of thing, but the palette's contents can't be edited or saved, the text can be copied to an open script editor window with the button on the right, the button on the left to copy to clipboard seems to be broken.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: How to get the properties defined in a Widget Extension

Post by OpenXTalkPaul »

So I searched the IDE files (the text script-only files at least) and this palette is in fact referenced by the 'Extension Manager' stack, in its list/row behavior, but I have no idea how it was intended to be used with extensions. There's no examples of any extensions that use this.
Anyway, Its kind of nice in that when it displays the text file it applies the script colorization. With a bit more work I think it could be useful as a scripting scrap book. I did already fix its broken 'copy to clipboard' button.
User avatar
OpenXTalkPaul
Posts: 2633
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: How to get the properties defined in a Widget Extension

Post by OpenXTalkPaul »

Here's a slightly better version of that Snippet Viewer that allows for drag & drop of text (including styled text) to set the contents of the field, and it's a 'float above everything' system window so it will stay visible when the ScriptEditor is open so you can drag drop selections of your scripts.
Plan to add a saving/loading of snippets, and add a button to get HTML text from the field (for putting code snippets into web pages).
snippet_viewer.zip
(3.81 KiB) Downloaded 132 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest