Drag images into text field

Mike Markkula acm at armas.com
Wed Jun 10 18:16:34 EDT 2009


This script works for me...

TheAllowableFileTypes global is just a list of the file types Rev handles
and is set in an openStack handler when the app is launched. The
³importImage² function imports the image, scales it to a size set in the
app¹s preferences, adds it to an images library stack, and returns the image
id number if successful.

-- This script handles dragging files from the finder to a field
-----------------------
on dragDrop
   global charNbrDroppedOn, theAllowableImageFileTypes,
theImagePlaceHolderChar
   put word 4 of the dropChunk into charNbrDroppedOn
   put the dragData["files"] into theFilePaths
   if the last char of theFilePaths is return then delete the last char of
theFilePaths
   set the itemDelimiter to "."
   repeat with k = 1 to the number of lines of theFilePaths
      set the cursor to busy
      put line k of theFilePaths into theFilePath
      if the last item of theFilePath is among the items of
theAllowableImageFileTypes then
         put importImage(theFilePath) into theImageID
         if theImageID is not empty then
            put charNbrDroppedOn - 1 + k into placeHolderChrNbr
            put theImagePlaceHolderChar after char placeHolderChrNbr of me
            put charNbrDroppedOn + k into targetChar
            set the imageSource of char targetChar of me to theImageID
         end if
      else -- process dropping the filepath
         put theFilePath & space after char charNbrDroppedOn of me
      end if
   end repeat
end dragDrop

HTH

Mike

On 6/10/09 2:33 AM, "Richmond Mathewson" <richmondmathewson at gmail.com>
wrote:

> The problem is that if you want to put an image into a textField you
> cannot;you
> can reference an image to replace a char:
> 
> e.g.    set the imageSource of char 15 of line 5 of fld "xx" to 1003
> 
> but this is a bit hopeless re drag-and-drop.
> 
> On Wed, Jun 10, 2009 at 3:47 AM, Josep <jmyepes at mac.com> wrote:
> 
>> 
>> Hi,
>> 
>> I need drag&drop some images into a text field. The question is drop the
>> images (little icons) between words into one text field. I drag&drop from a
>> web page that have the text with the images, but when drop into a text
>> field
>> only the text part is dropped. So the images I think that was drop after
>> the
>> text one by one.
>> After, I need to save it into a database. I test with htmltext but I
>> locked...
>> 
>> I haven't idea how to do it?
>> 
>> Salut,
>> Josep
>> --
>> View this message in context:
>> http://www.nabble.com/Drag-images-into-text-field-tp23953741p23953741.html
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>> 
> 
> 




More information about the use-livecode mailing list