Page 1 of 1

Frustration with Images and DataGrids

Posted: Mon Nov 11, 2013 11:34 am
by Traxgeek
Hi,

I've become frustrated (and angry with myself and LC to boot) whilst trying to populate an image in a datagrid at runtime.

I have a datagrid, on it is an image.
The image WAS a button BUT whilst I am able to change the button size at run-time, I seem unable to change the icon size of a button at runtime (say, when the user resizes the IDE)... I also seem to have to design any image that's going to be used on a button with the specific button size in mind (i.e., if my button is going to be 32p x 32p then I need to design / create an image to fit that size button). OK so far ? Or is this my first error ? ...

Anyway, the result is that, whilst I can make my button any size I like, I cannot change the icon size within that button at runtime... or... :oops:

I thought I'd swap the buttons for icons (I can resize icons and play with the 'lockloc'...)

Whilst this is no problem for a standard image control and all works just fine and dandy I cannot for the life of me to get this working within a data grid.

Then, after many hours I stumble across the following from Klaus (God bless you !) :

since I try not to rely on not so reliable LiveCode mechanisms :D
I usually import all of my images on ONE card that the user never sees. (I do the same.. so... all's good so far)

OK, I will have to note their IDs manually, but this way I can be sure
that all images are there in the standalone! (Absolutely, no great hardship)

And I always use buttons to display images, especially in DataGrids, (Uh Oh !!!! )
even if they do not act as a button.

I strongly advice to NOT copy any image into the "template" row! (Argggghhh !!!)
Use a button instead!

So, got it ! Use a button... but then, how to resize the icon of the button at run-time ?

Anyone able to shed some light on how to do this dynamically ?

Must confess, this sort of thing drives me nuts :twisted: ! Sorry !

Thanks in advance.

EDIT
One work-around here may well be to -1-resize the source image and then -2- reload the icon of the resized button with the resized image ? ? ? (deep breath) seems a long winded way but...

Re: Frustration with Images and DataGrids

Posted: Mon Nov 11, 2013 12:23 pm
by Klaus
Hi Trax,

I'm afraid the only way to change the way a datagrid looks is to modify its DGDATA
(the ICON that you set your button to in your case) and set it again, so the datagrid
will be redrawn with its new content. Know what I mean?

I did not find a reliable way of accessing the singel objects in the DATAGRID groups itself
with its nested and nested and nested groups.


Best

Klaus

Re: Frustration with Images and DataGrids

Posted: Mon Nov 11, 2013 12:32 pm
by Traxgeek
Thanks Klaus,

That just leaves me with (apart form a headache ! ) being able to reference source images contained / held on a hidden card... so 2 questions if I may :

-1- How do I populate a 'temporary' image with the contents of another ?
I've tried :
set the text of image "MyImage" of card "MyCard" to the text of image "MyOtherImage" of card "MySourceCard"
put image "MySourceImage" of card "MySourceCard" into image "MyImage"
put image id 2102544 of this stack into image id 2102783 of this stack
but without success... All code lines verify and run but nothing happens (and no errors are produced !) grrrr !

-2- I read (but can't find now) that there are problems including sub-stacks in a mobile standalone... I cannot now remember what but the reason for my asking is 'Am I better to put my app icons on a 'Resources' sub-Stack of on a hidden card within the main Stack ?

I must confess, I'm really having problems with populating button icons and images at run time... there are loads of examples (hence my attempts above) but few seem to work for me... not to mention the little gremlin with DataGrids, Images and population of said DG images at runtime form existing image controls contained within a hidden card / sub-Stack... driving me nuts... :evil:

Anyways, as always, very grateful !

Re: Frustration with Images and DataGrids

Posted: Mon Nov 11, 2013 12:42 pm
by Klaus
Hi Trax,

1. all that should work as exspected!?
You could try to lock screen/unlock screen to force the new images to appear.
but I am not sure if this does work in a datagrid.

I was thinking of really exchange the data in the datagrid and set the DGDATA again like this:
old dgdata:
...
tArray[1]["icon_in_button"] -> 1003 =ID of image in size x*x
...
NEW dgdata
...
## REpalce witjh BIGGER (or smaller) image
tArray[1]["icon_in_button"] -> 2045 =ID of image in size y*y
...
Know what I mean?

2. I doubt that SUBSTACKS with images make problens on the mobile platform!
In our current project we have thousands of external images in a substack that
we display nicely inside of buttons in the mainstack! :D


Best

Klaus

Re: Frustration with Images and DataGrids

Posted: Mon Nov 11, 2013 12:50 pm
by Traxgeek
Thanks Klaus