DRAG AND DROP

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

DRAG AND DROP

Post by smash » Sat Mar 14, 2009 9:50 am

i have different scrolling list fields, and i would like to just drag and drop selected items from the scolling list fields into a large text box.

now i have "sort of" worked out how to drag an item within the scrolling list to move, but i end up with
"text being dragged" instead of the actual name of the item, with this code

on dragData
set the dragData["text"] to "text being moved"
end dragData

now their are far too many items to list in the "text being moved" and i have no idea what the code would be to fix that
never alone work out how to drag it out of the box all together.

do i need to but a code in the handler box that i wish the dragged item to end up in ??
cheers

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Mar 14, 2009 12:59 pm

Hi smash,

since the syntax of Rev is VERY english like, you should try to put the things you want to achieve into "plain" english. After you did this you can almost "translate" this 1:1 into Rev.
Check out my example "simple_memory1" stack at the bottom of my webpage:
http://www.major-k.de/xtalke.html
for more info about this.

Like this:
1. I want to select text in a list field
2. I want to drag this "selectedtext" (Hint, Hint! :)) to another field
3. I want to DROP this text on that other field.
4. I want to replace the text in the otherfield/append it to that field

At lest this is how I understand what you wnat to do.
Hint: "dragdata" is not a valid COMMAND in Rev!

Translation:

1. No scripting necessary, since a list field does this automatically just by clicking the mouse.
2. You START to drag "the selectedtext of fld XYZ"so you have to handle "dragstart", see the docs.

So put this into the script of your listfield:

Code: Select all

on dragStart 
  set the dragData["text"] to the selectedtext of me
end dragStart
3. and 4. check DRAGDROP in the docs.
Put this into the script of your target field (your "large text box")

Code: Select all

on dragdrop
  ## 3.
  ## put the dragData["text"] into me
  ## 4.
  ## put CR & the dragData["text"] after me
end dragdrop
Just comment out the line that fit your needs.

Hope that helps.


Best

Klaus

smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash » Sat Mar 14, 2009 1:34 pm

evening klaus
ok i put this into the handlers list for scrolling list field
on dragData
set the dragData["Text"] to the selectedtext of me
end dragData
and this into the text field i was wanting to drag it to

on dragdrop
put the dragData["text"] into me
end dragdrop
but nothing is happening
now what am i doing wrong ???
(i know it is hard to believe a female could be wrong) lol lol :wink:

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Mar 14, 2009 1:46 pm

Hi smash (what a martial name for a young lady :D)

I did NOT write:

Code: Select all

on dragDATA 
set the dragData["Text"] to the selectedtext of me 
end dragDATA
And I also gave an appropriate hint!
Please read my post again!

Best

Klaus

smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash » Sat Mar 14, 2009 2:11 pm

*slinks back in and pops my glasses on*
whoops
*runs off to rectify my embarrassing moment*

ok i put this into my scrolling list field
on dragStart
set the dragData["Text"] to the selectedtext of me into field "results"
end dragStart
and this into the big box
on dragdrop
put the dragData["text"] into me
end dragdrop
on dragEnter
set the acceptDrop to true
end dragEnter
and still nothing happens.

now i printed pages 259 - 262 out of the docs this morning, and have been most of the day to understand how this works.


Hi smash (what a martial name for a young lady )
i know it is not very ladylike name at all, i will try to rectify that one day :wink:

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Mar 14, 2009 2:18 pm

Hi smash

I still did not write this:

Code: Select all

on dragStart 
  set the dragData["Text"] to the selectedtext of me INTO FIELD "RESULTS" 
end dragStart
Please polish your glasses :D


Best

Klaus

smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash » Sat Mar 14, 2009 2:26 pm

*runs up and gives you a peck on the cheek"
i know, i know
BUT
i had put this in also
on dragStart
set the dragData["text"] to the selectedtext of me
end dragStart
and that did not work either so i tried to "improvise" lol
obviously not very well by the tone of your voice LOL
i am trying klaus, (and no not your patience)
:oops:

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Mar 14, 2009 2:44 pm

Hi smash

hmm, tested here with an example stack and it works...?

I can send you this tiny stack, if you like, just send me you mailaddress to:
klaus@major-k.de


Best

Klaus

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Sat Mar 14, 2009 4:00 pm

Hi Klaus

Hope smash doesn't mind me asking you some questions via her thread; thank you in advance, smash!

• Is there some coding to actually see the line of type between dragged between the list box and the field, please?

• Could you give some indication of what else is needed in the on dragDrop script of a second scrolling List field; i.e so that a listField would accept a dragged line from another ListField please?

Klaus
Posts: 14197
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Mar 14, 2009 4:14 pm

Hi all,

to actualy SEE what you are dragging you need to take a snapshot of the "area to be dragged" and then set "the dragimage" to that image.

You will find an example for this (and a LOT more extremely beautiful and stunning example stacks of Scott Rossi at: http://www.tactilemedia.com/!
You will have to click "Software" then "Revolution..." and then scroll down for "Get In Line"...

And you should also check the fantastic tutorials of Eric Chatonet (RIP!) at his website: http://www.sosmartsoftware.com/?r=revolution&l=en.

I am sure you will find there what you are looking for :)


Best

Klaus

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Sat Mar 14, 2009 5:09 pm

Thank you for your quick reply, Klaus. I'll check those sites out now.

:)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Mar 14, 2009 10:15 pm

Dear Smash,

Have you noticed that people usually don't use ALL CAPS to write titles for their posts on this forum?

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash » Sat Mar 14, 2009 10:16 pm

MORNING KLAUS
i have tried to email you, but for some reason it wont send
so here is my email address
performancepintos@gmail.com

i would love to work out how this works,
THANK YOU KLAUS
Last edited by smash on Sun Mar 15, 2009 12:43 am, edited 2 times in total.

smash
Posts: 99
Joined: Tue Aug 19, 2008 5:18 am

Post by smash » Sat Mar 14, 2009 10:21 pm

oh sorry mark,
no i did not, but do now.

Post Reply