Community 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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Community widgets

Post by FourthWorld » Wed Apr 29, 2020 2:37 pm

The DataGrid is a good example of a custom control.

To make your own, put the objects it needs into a group, and set the group's selectGroupedControls property to false. Copy where needed. That's pretty much it.

To simplify maintenance you may want to put most of the group's code into a separate script, and have each instance use that script as its Behavior.

If you plan on using the custom control in multiple projects you may want to store that behavior script in a separate stack file. If you'll be using it in just one app the behavior script can be a substack in your main stack file, or even a button within that stack file.

Experiment with this and report back where we can help with any details.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

giovanni_c
Posts: 52
Joined: Sat Sep 08, 2012 10:50 am

Re: Community widgets

Post by giovanni_c » Tue May 05, 2020 1:40 pm

Hi Richard, thanks for feedback.
I will try what you suggest and will let you know.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Community widgets

Post by FourthWorld » Tue May 05, 2020 3:08 pm

A tip I forgot to include in my last post:

If you have the group adjust the positions of any controls inside it, you may find things much simpler if you see the lockLoc of the group to true.

By default groups will resize themselves to fit their contents, but with the lockLoc on you'll find they stay where you want them while your script adjusts things inside them.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

JereMiami
Posts: 119
Joined: Mon Nov 03, 2014 12:17 am

Re: Community widgets

Post by JereMiami » Fri Jan 22, 2021 4:19 pm

Anybody have any luck setting the imagesFolder property on the iconGrid widget (i.e., hhgrid) widget and/or setting the icons using objectsImageList in the slected imagesFolder?

It works when I move images into the hhjpg/ folder, but if I try any of my own local folders, it crashes or just does not work.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Community widgets

Post by FourthWorld » Fri Jan 22, 2021 5:13 pm

JereMiami wrote:
Fri Jan 22, 2021 4:19 pm
Anybody have any luck setting the imagesFolder property on the iconGrid widget (i.e., hhgrid) widget and/or setting the icons using objectsImageList in the slected imagesFolder?

It works when I move images into the hhjpg/ folder, but if I try any of my own local folders, it crashes or just does not work.
Crashing is a serious problem that should be submitted to the bug report queue. Nothing in a scripting language should crash.

As for not working, what is the full path you're using, and if you that to the exists function does it confirm the path as written is correct?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

JereMiami
Posts: 119
Joined: Mon Nov 03, 2014 12:17 am

Re: Community widgets

Post by JereMiami » Fri Jan 22, 2021 5:39 pm

Here's the script:

Code: Select all

 
 if the environment is "mobile" then 
      put specialFolderPath("resources") & "/images/" into tPath
      put the objectsImageList of widget "IconGrid" into tArray
      put "meals_image_01.jpg" into tArray["1"]
      put "meals_image_02.jpg" into tArray["2"]
      put "meals_image_03.jpg" into tArray["3"]
      put "meals_image_04.jpg" into tArray["4"]
      put "meals_image_05.jpg" into tArray["5"]
      put "meals_image_06.jpg" into tArray["6"]
      put "meals_image_07.jpg" into tArray["7"]
      put "meals_image_08.jpg" into tArray["8"]
      set the imagesFolder of widget "IconGrid" to tPath
      set the objectsImageList of widget "IconGrid" to tArray
   else
      put "C:/Users/jrj25/OneDrive/Desktop/images/" into tPath
      set the imagesFolder of widget "IconGrid" to tPath
      get the objectsImageList of widget "IconGrid"
      put it into tArray    
      put "meals_image_01.jpg" into tArray["1"]
      put "meals_image_02.jpg" into tArray["2"]
      put "meals_image_03.jpg" into tArray["3"]
      put "meals_image_04.jpg" into tArray["4"]
      put "meals_image_05.jpg" into tArray["5"]
      put "meals_image_06.jpg" into tArray["6"]
      put "meals_image_07.jpg" into tArray["7"]
      put "meals_image_08.jpg" into tArray["8"]
      set the objectsImageList of widget "IconGrid" to tArray
The above code will either crash LC or not display the images (with an error wrt to LCB). Any ideas what I am doing wrong? It is an excellent widget when using the built in "hhjpeg" folder when you put images into it. It would be awesome if you could source your own local folder though.

PaulDaMacMan
Posts: 617
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Community widgets

Post by PaulDaMacMan » Wed Feb 10, 2021 4:02 am

On HH's website it says: "All widgets are MIT licensed (if source code included) or else CC-BY licensed.
The LCB source for HH's icon grid is included in the extension, change the .lce to .zip and extract it.
Last edited by PaulDaMacMan on Wed Feb 10, 2021 3:47 pm, edited 1 time in total.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

PaulDaMacMan
Posts: 617
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Community widgets

Post by PaulDaMacMan » Wed Feb 10, 2021 2:03 pm

@JereMiami
I just did some testing with HH's icon grid (2.1.1) on macOS 10.14.6 and I was able to use the property inspector to change the imagesFolder prop and manually edit elements of the objecstImageList array prop without any crashing, although the widget does not do any filtering of macOS invisible files, or testing that the file you pass is actually an image, and it's a bit difficult to use the PI for editing it. I kept getting LCB errors thrown, but I turned on 'suppress errors' and that helped. I didn't try setting it programmatically. It looks like your image names must include a tag <imagesFolder> in front of the filename, which gets replaced by the widget with the imagesFolder property behind the scenes, so your code should look something like:

Code: Select all

 
 set the imagesFolder of widget "hhGrid" to  specialFolderPath("resources") & "/images/"
 put "<imagesFolder>meals_image_01.jpg" into tArray["1"]
 -- etc.
 
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

JereMiami
Posts: 119
Joined: Mon Nov 03, 2014 12:17 am

Re: Community widgets

Post by JereMiami » Thu Mar 18, 2021 3:39 am

Thanks for looking into it. Going to head back to it next week. Let you know how it goes.

Post Reply

Return to “LiveCode Builder”