How can i create image selection field?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How can i create image selection field?
Hi.
How can i create image selection field? So that have one field and i click on it the left or right mouse and i can choose an image from my hard drive and show in field?
How can i create image selection field? So that have one field and i click on it the left or right mouse and i can choose an image from my hard drive and show in field?
Re: How can i create image selection field?
Hi.
Do you really want to use a field for this, as opposed to a button? Not that it matters, I was just wondering. Anyway, in either a button or a locked field, place this in the script (pseudo):
Setting the lockLoc is important. Try not doing so and see what happens. A cool thing here is the use of the "last" keyword. This comes in handy in just this sort of case. You can:
If you need more help with any of the above, write back...
Craig
Do you really want to use a field for this, as opposed to a button? Not that it matters, I was just wondering. Anyway, in either a button or a locked field, place this in the script (pseudo):
Code: Select all
on mouseUp tButton
if tButton = "1" then
import paint from file "yourFilePathHere"
set the rect of last image to "20,20,200,200" --just an example
set the lockLoc of last image to "true"
set the loc of last image to whereverYouWish
else if tButton = 3 then
--another file path to an image
end mouseUp
Code: Select all
set the name of last img to "whatever"
Craig
Re: How can i create image selection field?
Hi,
You may use imagesource
Best regards
Jean-Marc
You may use imagesource
Code: Select all
set the imageSource of character to {imageID | imageName | imageURL |empty}
Jean-Marc
https://alternatic.ch
Re: How can i create image selection field?
Thanks for helping. I get error code in line 9: missing 'end if' command.
Re: How can i create image selection field?
Seal29.
That is why I mentioned "(pseudo)".
This was not a working handler.
Do you need a working sample handler to get going? Since you are "live" with me right now, I can do that for you.
Craig
That is why I mentioned "(pseudo)".
This was not a working handler.
Do you need a working sample handler to get going? Since you are "live" with me right now, I can do that for you.
Craig
Re: How can i create image selection field?
Anyway, here (and this is pseudo again, since things like "yourFilePathHere" are placeholders, not real LiveCode words):
Craig
Code: Select all
on mouseUp tButton
if tButton = "1" then
import paint from file "yourFilePathHere"
set the rect of last image to "20,20,200,200" --just an example
set the lockLoc of last image to "true"
set the loc of last image to whereverYouWish
else if tButton = 3 then
import paint from file "yourOTHERFilePathHere"
set the rect of last image to "20,200,200,400" --just another example
set the lockLoc of last image to "true"
set the loc of last image to whereverELSEYouWish
end if
end mouseUp
Last edited by dunbarx on Fri Oct 02, 2020 5:06 pm, edited 1 time in total.
Re: How can i create image selection field?
Jean-Marc.
An interesting idea, especially since the OP mentioned using a field. But won't this get a bit crowded in a single field, applying imageSources to various chars? I got the feeling that several images were intended to be loaded.
Craig
An interesting idea, especially since the OP mentioned using a field. But won't this get a bit crowded in a single field, applying imageSources to various chars? I got the feeling that several images were intended to be loaded.
Craig
Re: How can i create image selection field?
Thanks for the great help.dunbarx wrote: ↑Fri Oct 02, 2020 5:02 pmAnyway, here:
CraigCode: Select all
on mouseUp tButton if tButton = "1" then import paint from file "yourFilePathHere" set the rect of last image to "20,20,200,200" --just an example set the lockLoc of last image to "true" set the loc of last image to whereverYouWish else if tButton = 3 then import paint from file "yourOTHERFilePathHere" set the rect of last image to "20,200,200,400" --just another example set the lockLoc of last image to "true" set the loc of last image to whereverELSEYouWish end if end mouseUp
Re: How can i create image selection field?
SEAL29
Read my edited lastMost post to you, not Jean-Marc, about "pseudo"
Craig
Read my edited lastMost post to you, not Jean-Marc, about "pseudo"
Craig
Re: How can i create image selection field?
Hi SEAL29,
welcome to the forum!
If you want to select an image from your HD, do like this:
Best
Klaus
welcome to the forum!
If you want to select an image from your HD, do like this:
Code: Select all
on mouseup
## Show the system OPEN dialog:
answer file "Please select an image file." with type "Images|jpg,jpeg,gif,png|"
## IT contains the path of the selected image file
put it into tFile
## Check if user clicked CANCEL
if the result = "Cancel" then
## No need to conttinue in this case!
exit mouseup
end if
## Now continue like Craig suggested:
## Import that image file into your stack:
import paint from file tFile
set the rect of last image to "20,20,200,200" --just an example
## ...
end mouseup
Klaus
Re: How can i create image selection field?
Hi Craig,
Yes, you're probabily right to invite SEAL29 to reconsidere use a fld to display image.
Best
Jean-Marc
Yes, you're probabily right to invite SEAL29 to reconsidere use a fld to display image.
Best
Jean-Marc
https://alternatic.ch
Re: How can i create image selection field?
Thanks Klaus this is what i was looking for.Klaus wrote: ↑Fri Oct 02, 2020 5:31 pmHi SEAL29,
welcome to the forum!
If you want to select an image from your HD, do like this:BestCode: Select all
on mouseup ## Show the system OPEN dialog: answer file "Please select an image file." with type "Images|jpg,jpeg,gif,png|" ## IT contains the path of the selected image file put it into tFile ## Check if user clicked CANCEL if the result = "Cancel" then ## No need to conttinue in this case! exit mouseup end if ## Now continue like Craig suggested: ## Import that image file into your stack: import paint from file tFile set the rect of last image to "20,20,200,200" --just an example ## ... end mouseup
Klaus

Million thanks to everyone, you are all very helpful. Thanks.
Re: How can i create image selection field?
SEAL29.
I should have guessed that you needed help with securing the pathname. This will all come as you work through stuff and solve problems.
Don't be shy. Ask for details.
Craig
I should have guessed that you needed help with securing the pathname. This will all come as you work through stuff and solve problems.
Don't be shy. Ask for details.
Craig
Re: How can i create image selection field?
It is possible to store only the image reference and not the whole picture (with script). Since there are many images will have a large file size over time?
Re: How can i create image selection field?
SEAL29.
If you plan on large numbers of images, I would store them in an external file and load as required. This keeps your stack lean. Loading an image takes no time, and external files do not care how large they are. In this way, you only need LC to present the particular image you need.
If you are making a standalone, you must include that file in the standalone settings.
Craig
If you plan on large numbers of images, I would store them in an external file and load as required. This keeps your stack lean. Loading an image takes no time, and external files do not care how large they are. In this way, you only need LC to present the particular image you need.
If you are making a standalone, you must include that file in the standalone settings.
Craig