DragMove Message

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

DragMove Message

Post by WaltBrown » Wed Sep 21, 2011 4:16 am

I can't seem to get a dragMove message. I have this:

Code: Select all

on mouseDown
   grab me
end mouseDown

on dragMove
   put "Obj" && the mouseLoc into fld "fData"
end dragMove
in an empty opaque graphic object. I have tried dragMove handlers in it, and the card and the stack scripts. I have tried "pass dragMove" in each one. I have also tried setting SetAllowableDragActions and DragAction properties in a dragStart message handler. I do get the dragStart message.

I also don't get "dragMove" messages in the MessageWatcher. I do get dragStart messages in the MessageWatcher, along with cREVTable and cREVGetUpdate messages when I release the mouse after dragging.

Oddly enough, after dragging the object around, and only after dragging the object around, the first time I click in the field I get a cREVGeneral and a scrollbarDrag message.

I imagine it's pilot error, I'm just missing something. Any thoughts?

Thanks,
Walt
Walt Brown
Omnis traductor traditor

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

Re: DragMove Message

Post by Mark » Wed Sep 21, 2011 9:58 am

Hi Walt,

The grab command is a blocking command, will not fire any additional messages while being used and has nothing to do with drag-related functions. Check out the dragdata in the documentation and look at "see also".

Kind 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

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: DragMove Message

Post by WaltBrown » Wed Sep 21, 2011 4:24 pm

Thanks Mark, I didn't "get" that when I read the Dictionary. I submitted your comment as a Note.
Walt Brown
Omnis traductor traditor

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: DragMove Message

Post by mwieder » Wed Sep 21, 2011 8:07 pm


WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: DragMove Message

Post by WaltBrown » Thu Sep 22, 2011 3:47 am

Thanks Mark, I hadn't seen that.
Walt Brown
Omnis traductor traditor

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: DragMove Message

Post by marksmithhfx » Sun Oct 02, 2011 4:24 pm

Walt, I don't know if this helps or not but I just posted a stack (enhanced scrolling list) that does some image dragging. It does not use the grab command. Basically things get initialized after receiving the dragstart message. I setup a few parameters so I know when to do autoscrolling in the field, and I set a flag (dgstart) so I know in various other handlers if I am in the middle of a drag or not. Bernd Niggemann, who did the dragimage routine, gets a "snapshot" of the selected line (after first copying it to a hidden field) and then positions it under the mouse pointer with:

set the topLeft of image sDragImage to the left of me & "," & the mouseV - sYDiff

This all happens in the dragstart handler. Basically Bernd keeps the image moving around in the mousemove handler using the same line of code (after first checking dgstart to make sure we are in the middle of a drag) while I track where we are in the list and move items around to create a "space" for the dragged image to be "dropped" into (well, thats the visual illusion anyway!).

The process ends in mouseup or mouserelease at which point I double check to make sure I am in the right place in the list to "drop" (ie. insert) the moved line and then Bernd deletes his image after that. We reset all the flags and variables in particular dgstart so we know we are not dragging anymore. So basically three handlers (dragstart, mousemove and mouseup (or mouserelease)) in that order. Frankly all of this was constructed through trial and error so I don't know if it conforms with 'accepted practice' or not, but in this case it appears to be working well. Now that I semi-undertand this I plan to go read "pinning drag and drop to the mat" :)

Hope it helps,
-- mark
Last edited by marksmithhfx on Sun Oct 02, 2011 5:07 pm, edited 1 time in total.
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: DragMove Message

Post by marksmithhfx » Sun Oct 02, 2011 4:38 pm

Ooops, just noticed you are on a PC. You can enable drag drop by deleting the if statement in dragstart

if the machine <> "x86" then -- disable drag/drop on PC's until bug #7766 is fixed

which will work fine as long as you then avoid using the popup. The two are currently incompatible on the x86.

-- Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: DragMove Message

Post by WaltBrown » Mon Oct 03, 2011 4:53 am

Thanks, I think I found and mentioned 7766 in another thread as well.
Walt Brown
Omnis traductor traditor

Post Reply