Community widgets
-
- VIP Livecode Opensource Backer
- Posts: 9847
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Community widgets
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.
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 52
- Joined: Sat Sep 08, 2012 10:50 am
Re: Community widgets
Hi Richard, thanks for feedback.
I will try what you suggest and will let you know.
I will try what you suggest and will let you know.
-
- VIP Livecode Opensource Backer
- Posts: 9847
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Community widgets
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.
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Community widgets
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 9847
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Community widgets
Crashing is a serious problem that should be submitted to the bug report queue. Nothing in a scripting language should crash.JereMiami wrote: ↑Fri Jan 22, 2021 4:19 pmAnybody 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.
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Community widgets
Here's the script:
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.
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
-
- Posts: 632
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Community widgets
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.
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.
-
- Posts: 632
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Community widgets
@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:
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.
Re: Community widgets
Thanks for looking into it. Going to head back to it next week. Let you know how it goes.