Getting properties and active handlers of a widget

Moderators: LCMark, LCfraser

Post Reply
pthirkell
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 93
Joined: Tue Nov 17, 2009 6:47 pm
Location: Wellington, New Zealand

Getting properties and active handlers of a widget

Post by pthirkell » Tue May 03, 2016 1:47 am

I can "get the kind of widget 1" which helpfully provides the necessary widget identifier (e.g. "com.livecode.widget.colorswatch"). For other object types I can "get the properties" - but seemingly not for widgets. Is there a command that allows me to easily access a widget's properties?

Also, is there a way to list the handlers to which a widget of any specified kind will respond in LCS (e.g. mouseup, dragstart, etc)? I know that viewing the LCB script will allow me to figure this out, but it would be great to be able to list all active widget handlers at a glance.

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 168
Joined: Thu Apr 18, 2013 2:48 pm

Re: Getting properties and active handlers of a widget

Post by livecodeali » Tue May 03, 2016 9:24 am

There is currently no engine function to get either of these, although they can both obtained by parsing some additional files.

The complete list of handlers implemented in a widget is available in its 'interface' file. This is located at revIDESpecialFolderPath("Toolchain") & "/modules/lci/<extensionID>.lci". I think it would be a good idea for this to be documented for convenience, perhaps in the widget's user guide (these do not exist yet), or somewhere in the dictionary entry.

The list of properties a widget implements can be found in its manifest.xml file, which is located at revIDESpecialFolderPath("Extensions") & "/<extensionID>/manifest/xml", although as these are parsed already by the IDE when an extension is loaded, you can get the list using the revIDEExtensionProperties(<extensionID>) function, eg

put the keys of (revIDEExtensionProperties("com.livecode.widget.treeView"))

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2689
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Getting properties and active handlers of a widget

Post by mwieder » Wed Jun 14, 2017 10:52 pm

Here's how I'm getting the handlers currently:

Code: Select all

/**
* find the extension interfaces folder
*/
private function modulesLocation
   return specialfolderpath("engine") & "/Toolchain/modules/lci/"
end modulesLocation

/**
* given a module name
* return a list of its public handlers
*/
function widgetAvailableHandlersOfModule pModule
   local tFile
   local tContents
   
   put modulesLocation() & "com.livecode." & pModule & ".lci" into tFile
   put url ("file:" & tFile) into tContents
   filter tContents with "*handler*"
   return tContents
end widgetAvailableHandlersOfModule


mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2689
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Getting properties and active handlers of a widget

Post by mwieder » Thu Jun 15, 2017 1:36 am

because note that revIDEspecialFolderpath("engine") returns nothing on linux.

Post Reply

Return to “LiveCode Builder”