Adding images to Fields ?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MCla
Posts: 11
Joined: Sat Feb 20, 2010 5:37 am

Adding images to Fields ?

Post by MCla » Wed Sep 15, 2010 2:56 am

I am preparing a help/info stack for an ecosystem analysis program.
There are quite a few equations and other small graphics I would like to add to scrolling fields that contains various font sizes, colors etc..(formatted text).

How do you add graphics in a scrolling field. Is this possible, easy. Or should I go a different way ?

Cheers,

Michel

Regulae
Posts: 136
Joined: Tue Oct 20, 2009 6:05 am

Re: Adding images to Fields ?

Post by Regulae » Wed Sep 15, 2010 6:52 am

Hi there,

“imageSource” may suit your needs. This lets you assign an image to a character in a field (including scrolling fields). The Rev dictionary gives some examples:
set the imageSource of char 1 of line 2 of field "This" to 2533
set the imageSource of char thisChar of field 1 to "Arrow"
set the imageSource of last char of me to "binfile:My Image"
To automatically allow line space to display an image (which could be considerably bigger than the surrounding text) set the fixedLineHeight of the field to false. You mention your fields contain text of various sizes, so it sounds like the fixedLineHeight of the fields you are using is already set to false, but I thought it a useful thing to mention. I hope this helps.

Edit: another text property worth mentioning is "textShift", which may help adjust the alignment of images with surrounding text. Again, from the Rev dictionary:
set the textShift of last char of word 2 of field 1 to 3 -- subscript
set the textShift of char 12 of the selectedField to -1 -- superscript
Regards,
Michael

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Re: Adding images to Fields ?

Post by shadowslash » Thu Sep 16, 2010 4:59 pm

or you can also use:

Image
Parañaque, Philippines
Image
Image

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Contact:

Re: Adding images to Fields ?

Post by Nonsanity » Mon Feb 21, 2011 6:54 am

If I have a variable that was filled with a line like this:

Code: Select all

put url aTempImageURL into myImg
I can do this:

Code: Select all

set the text of img 1 to myImg
But these do not work:

Code: Select all

set the imageSource of char 1 of fld 1 to myImg
set the imageSource of char 1 of fld 1 to the imagedata of img 1
set the imageSource of char 1 of fld 1 to img 1
Is there a way to set a character's imageSource with data like this?
~ Nonsanity
~ Chris Innanen

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Adding images to Fields ?

Post by jmburnod » Mon Feb 21, 2011 3:25 pm

Hi Nonsanity,

Code: Select all

set the imageSource of char 1 of fld 1 to the imagedata of img 1
dont work
but

Code: Select all

set the imageSource of char 1 of fld 1 to the short id of img 1
work
Best

Jean-Marc
https://alternatic.ch

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Contact:

Re: Adding images to Fields ?

Post by Nonsanity » Mon Feb 21, 2011 3:38 pm

Thanks, Jean-Marc.

I thought about that possibility once, but then thought that it would be silly. Makes sense now though. I should have at least tried it.
~ Nonsanity
~ Chris Innanen

Post Reply