Page 1 of 1

Default handler list

Posted: Sun Dec 09, 2018 12:02 pm
by pink
I can't seem to get this working.

How do I add custom handlers to the handler list? Or builtin handlers for that matter?

Re: Default handler list

Posted: Sun Dec 09, 2018 5:52 pm
by [-hh]
Import examples:
use com.livecode.math
use com.livecode.library.iconsvg

In case you mean with "custom handlers" public handlers of other widgets:
Such handlers aren't really "public". This is not (yet) implemented in LCB.

Re: Default handler list

Posted: Sun Dec 09, 2018 5:59 pm
by pink
As an example, on the "Segmented Control" widget, there is the "hiliteChanged" handler, and on the "Tree View" widget there is "actionDoubleClick, actionInspect, dataChanged, hiliteChanged" handlers listed.

I would like to add handlers such as these to the list on the left when I open the script editor for one.

Re: Default handler list

Posted: Sun Dec 09, 2018 6:15 pm
by [-hh]
There is no direct connection between LCS editor and LCB-widgets.
The only way I can see is that you build a template with all the properties (may be based on the manifest.xml file of the widget) and set the script of an LCS object to that template.

For adding handlers to the "insert"-List you have to dive into the IDE.
Probably you can use the menu action of the LC menu "Handler/Add default handler ..."

Re: Default handler list

Posted: Mon Dec 10, 2018 12:34 am
by bwmilby
Those examples are messages that the widget sends. You should be able to add them just like the LC default widgets. They are included in the docs at the top of the widget.

The default script/comments appear to be copied from support/defaultscript.livecodescript for each handler that is added.

Re: Default handler list

Posted: Thu Dec 13, 2018 3:04 pm
by [-hh]
I now followed the defaultscript generating for a widget in detail.

[1] There is probably a problem with
Tools/Toolset/libraries/revidedeveloperextensionlibrary.livecodescript, line 639:

Code: Select all

  put sExtensionDetailsA[pFolder]["name"] & ".__DefaultScript" into tExpectedName
I think this should read "DefaultScript" instead of ".__DefaultScript"
This may be the reason why a default script is found not before a second edit in the Extension Builder. But it has no influence on installing a widget.

[2] The installation of the widget runs correctly and the defaultscript.livecode file has the expected path.
[3] The defaultscript doesn't load correctly into the cache:
In file Tools/Toolset/libraries/revideextensionlibrary.livecodescript the defaultscript is correctly loaded (I checked manually with revIDEExtensionFetchDefaultScript**) and set as key, line 1170:

Code: Select all

   put revIDEExtensionFetchDefaultScript(pFolder, pID, true) into tDefaultScript
   __extensionPropertySet tCacheIndex, "defaultScript", tDefaultScript
But I couldn't get it as key, so there may be a problem with the cache building. I don't know where. (Of course I removed the cache and looked into a fresh build of it).

__
** For example from the message box:
put "/Users/admin/Documents/My LiveCode/Extensions/community.livecode.hermann.graphicswidget.1.0.0" into tFolder
put revIDEExtensionFetchDefaultScript(tFolder)

So we can (at least for testing) edit tFolder/support/defaultscript.livecodescript with a texteditor and revIDEExtensionFetchDefaultScript(tFolder) loads it.