Quantcast
Channel: LiveCode Forums
Viewing all articles
Browse latest Browse all 757

Getting Started with LiveCode - Complete Beginners • Re: Drag & Drop?

$
0
0
Hi Jon,

I changed your script just a little bit and it works for me with .txt files, see "## changed"

CODE:

on dragEnter   -- Check if the dropped item is a file   if dragData["Files"] is not empty then ## changed      set the dragAction to "copy" -- Visual feedback for dragging   end ifend dragEnteron dragDrop   -- Check if the dropped item is a file   if dragData["Files"] is not empty then ## changed      -- Get the file path from the drag data      put the dragData["files"] into tFilePath            -- Ensure only one file is processed (if multiple files are dragged)      put line 1 of tFilePath into tFilePath            -- Validate that the file is a text file      if char -4 to -1 of tFilePath is ".txt" then         -- Read the contents of the file         put URL ("file:" & tFilePath) into tFileContents                  -- Place the file contents into the "Specs" field         put tFileContents into field "Specs"      else         -- Notify user if the file is not a text file         answer "Please drop a valid text file." with "OK"      end if   end ifend dragDrop
Kind regards
Bernd

Statistics: Posted by bn — Wed Nov 20, 2024 12:35 am



Viewing all articles
Browse latest Browse all 757

Trending Articles