Default handler list

Moderators: LCMark, LCfraser

Post Reply
pink
Posts: 242
Joined: Wed Mar 12, 2014 6:18 pm

Default handler list

Post by pink » Sun Dec 09, 2018 12:02 pm

I can't seem to get this working.

How do I add custom handlers to the handler list? Or builtin handlers for that matter?
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1956
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Default handler list

Post by [-hh] » Sun Dec 09, 2018 5:52 pm

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.
shiftLock happens

pink
Posts: 242
Joined: Wed Mar 12, 2014 6:18 pm

Re: Default handler list

Post by pink » Sun Dec 09, 2018 5:59 pm

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.
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1956
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Default handler list

Post by [-hh] » Sun Dec 09, 2018 6:15 pm

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 ..."
shiftLock happens

bwmilby
Posts: 244
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Default handler list

Post by bwmilby » Mon Dec 10, 2018 12:34 am

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.
Brian Milby

Script Tracker https://github.com/bwmilby/lc-misc/tree/master/ScriptTracker

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1956
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Default handler list

Post by [-hh] » Thu Dec 13, 2018 3:04 pm

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.
shiftLock happens

Post Reply

Return to “LiveCode Builder”