Creating a module for use by widgets?

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Creating a module for use by widgets?

Post by trevordevore » Thu Sep 24, 2015 5:17 am

I have a number of UI widgets now. I would like to move common handlers to a separate module. I want the handlers defined in the module to be accessible to widgets the <use> it. I don't want it in the message path of LCS. I tried the following code in an .lcb file as I thought a <module> would accomplish what I want:

Code: Select all

module com.livecode.extensions.xyz.uicontrol

use com.livecode.canvas
use com.livecode.engine

public handler AdjustColorForEnabledState(in pColor as Color, in pEnabled as Boolean) returns Color
   if pEnabled then
		set the alpha of pColor to 1
	else
		set the alpha of pColor to 0.5
	end if
end handler

end module
When trying to <Test> with the Extension Builder I get the following error:

Code: Select all

12:13 AM: Fetching metadata from /Users/xyz/lc-modules/UIControl/manifest.xml
12:13 AM: Error: couldn't retrieve extension type from manifest /Users/xyz/lc-modules/UIControl/manifest.xml
12:13 AM: Error: Could not compile module /Users/xyz/lc-modules/UIControl
Is there a way to accomplish what I'm after? If so, what is the correct way?
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

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

Re: Creating a module for use by widgets?

Post by livecodeali » Thu Sep 24, 2015 9:36 am

Hi Trevor,

Funnily enough, I just did this for our widgets:
https://github.com/livecode/livecode-ide/pull/511

and uncovered the fact that modules when compiled don't output a type field to the manifest.
That's what's causing the bug.

This https://github.com/livecode/livecode-ide/pull/511 works around it, but I think the proper fix is to have modules declare themselves to be of module type.

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

Re: Creating a module for use by widgets?

Post by livecodeali » Thu Sep 24, 2015 10:18 am

Ok, here is the correct fix.

https://github.com/livecode/livecode/pull/2918

If your module identifier has three components, you will have still have an issue with the IDE thinking the module is builtin and therefore not trying to load it. I will try to fix that asap.

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Creating a module for use by widgets?

Post by trevordevore » Thu Sep 24, 2015 4:07 pm

Thanks @livecodeali. It works!

One other question - right now it seems that if I want to change my shared module I have to uninstall it, quit LiveCode, make my code changes, relaunch LiveCode, and then reinstall it. Is there an easier way?
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

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

Re: Creating a module for use by widgets?

Post by livecodeali » Sat Sep 26, 2015 5:08 pm

Hmm, good question. I suspect because your other loaded modules have references to it, there currently isn't a way of doing that. I presume you've tried doing this via the extension builder without restarting and it said "Error: module with that name already loaded" or something similar?

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Creating a module for use by widgets?

Post by trevordevore » Sat Sep 26, 2015 9:13 pm

I don't get any errors from the Extensions Builder. It appears as if everything worked but my changes don't show up. I just tested again and I don't have to go through the uninstall step. But I do have to restart.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply

Return to “LiveCode Builder”