Drag and Drop

Deploying to Linux? Get penguinated here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Drag and Drop

Post by malte » Mon Jun 08, 2015 8:46 pm

Hi,

I am trying to get drag and drop to work on UBUNTU 14.0.4 LTS 64 - Bit.

So far no luck. Was anyone of you successful?

Best,

Malte

MaxV
Posts: 1342
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Drag and Drop

Post by MaxV » Tue Jun 09, 2015 1:05 pm

It works, I just tested this code:

########CODE#######
on dragEnter
if "image" is in keys(the dragData) or "files" is in keys(the dragData) then
set the foregroundcolor of the target to "green"
set the dragAction to "copy"
else
set the dragAction to "none"
end if
end dragEnter

on dragLeave
set the foreGroundColor of the target to empty
end dragLeave

on dragDrop
put "gif,jpg,bmp" into immagini
if "files" is in keys(the dragData) then
# è una lista di immagini
repeat for each line theLine in the dragData["files"]
set itemdel to "."
put the last item of theLine into testfile
set itemdel to ","
if lower(testfile) is among the items of immagini then
import paint from file theLine
end if
end repeat
else
#è un'immagine portata da un programma
create image
put the dragData["image"] into last image
end if
set the foreGroundColor of the target to empty
end dragDrop
#####END OF CODE#####

Livecode 6.7.5 and Ubuntu
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1540
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Drag and Drop

Post by [-hh] » Mon Dec 21, 2015 10:51 pm

Hi,
using the dragData["files"] on Linux (Xubuntu 1504) I get

in 6.7.8 (as expected):     file://<filepath> where <filepath> is the usual full unix filepath .
in 7.1.1:                           cryptic unicode data (looks like UTF16), but I cannot decode it.
in 8.0.0-dp12:                 not usable, sometimes gives text, sometimes crashes.

How can I get from dragdata["files"] in LC > 6 an usable result?

All three LC versions above work fine in MacOS 10.11 and Win 10.
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5393
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Drag and Drop

Post by FourthWorld » Tue Dec 22, 2015 2:27 am

I've been using the dragData["files"] successfully on v6, 7, and 8 within a dragDrop handler. There was a bug with that in early versions of v7, but addressed quite some time ago. In what context is it not working for you?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1540
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Drag and Drop

Post by [-hh] » Tue Dec 22, 2015 3:55 am

This is in LC 7.1.1/Xubuntu in a simple dragEnter handler (or dragDrop), that works always on Mac/Win,
and also Linux/LC 6.7.8

put line 1 of the dragData["files"]

On Mac/Win I get the usual 'unix' path, in Linux prepended by "file://", should be here "file:///home/hh/Pictures/caledonian.jpg"
what I get is in the attached screenshot (can't even copy the output)
on Xubuntu1504/LC 7.1.1.
Attachments
Xubuntu1504-LC711.png
shiftLock happens

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1540
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Drag and Drop

Post by [-hh] » Tue Dec 22, 2015 10:29 am

Found a workaround. It is not a 'regular unicoded' filePath in 7.1.1, so we have to replace the second Null-bytes were they are (which is not totally as usual).

The next three lines give a workaround for those who have problems with the possible occuring LC 7.1. dragdata["files"]-bug.
This doesn't change anything for other OSes --and LC versions , they work as well with this code:

Situation: dragDrop a *single* file icon to a stack. (Of multiple files we use the first in the list).

Code: Select all

put line 1 of the dragData["text"] into f
replace numToByte(0) with empty in f
replace "file:" with empty in f
f is now a usual file path as needed for Mac/Win/Linux (incl. Raspi).

Once again, for beginners, used in a dragDrop handler:

Code: Select all

on dragDrop
   put line 1 of the dragData["text"] into f
   replace numToByte(0) with empty in f
   replace "file:" with empty in f
    -- your checks for img or text here -->  as MaxV explained above
    --
    --[1] image file was dropped, replaces an existing image
    put url("binfile:"&f) into iData
    set text of img iTarget to iData
    --
    --[2] text file was dropped, replaces text of an existing field
    put url("file:"&f) into iData
    set text of fld iTarget to iData
    --
    -- your final work here
end dragDrop
shiftLock happens

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5393
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Drag and Drop

Post by FourthWorld » Tue Dec 22, 2015 4:26 pm

A while back I'd seen this on Ubuntu, but haven't been able to reproduce it since v7.1 so I closed my report:
http://quality.livecode.com/show_bug.cgi?id=14834

Searching the bug DB for related issues I found this one, which seems to cover the symptoms you describe and is still open:
http://quality.livecode.com/show_bug.cgi?id=14494

I'm not sure how my situation got resolved; possibly setting a global property like allowDrops or something, I'll have to explore to see if I can reproduce the issue again.

In the meantime, please feel free to submit any additional info you have to the report for bug #14494.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

MaxV
Posts: 1342
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Drag and Drop

Post by MaxV » Thu Dec 24, 2015 9:46 am

This issue is resolved in Livecode 7.1.1 rc4
I think that it's unicode related...
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1540
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Drag and Drop

Post by [-hh] » Thu Dec 24, 2015 10:04 am

Hi Max,
I tested here on Xubuntu 1504 and found the problem with the *stable* version LC 7.1.1.
It's an uncompletely unicoded path, that's why unidecode doesn't work.
Hermann

Have a good end of the year!
shiftLock happens

MaxV
Posts: 1342
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Drag and Drop

Post by MaxV » Mon Dec 28, 2015 3:17 pm

Linux mint 17.2 and livecode 7.1.1rc4 works well...
I'm perplexed :?:
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5393
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Drag and Drop

Post by FourthWorld » Mon Dec 28, 2015 3:53 pm

[-hh] wrote:I tested here on Xubuntu 1504 and found the problem with the *stable* version LC 7.1.1.
32-bit or 64-bit?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1540
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Drag and Drop

Post by [-hh] » Mon Dec 28, 2015 4:37 pm

Good question.
I use LC 7.1.1 32 bit/x86. Tested again on Xubuntu 15.10 (wily) and see the 'defect'.
shiftLock happens

MaxV
Posts: 1342
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Drag and Drop

Post by MaxV » Tue Dec 29, 2015 2:53 pm

64 bit version is ok for me
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Linux”