How to do drag'n'drop?

BlitzMax Forums/BlitzMax Programming/How to do drag'n'drop?

REDi(Posted 2005) [#1]
I'm trying to drag and drop from one canvas to another, but I'm having a few problems...

1. When you release the mouse button, the EVENT_MOUSEUP EventSource is the original canvas. (as expected, but it would have been nice anyway)
2. When you click and drag, it seems to ignor all other events apart from the ones from the original canvas, until you release the mouse button again, so I can't use EVENT_MOUSEENTER/MOUSELEAVE to catch it myself.

Simple tester...


Any ideas how to do it?

*EDIT* BTW going to work now, so wont be around for about 12hrs :(


MattVonFat(Posted 2005) [#2]
I have no idea how you would do this but couldn't you create an EVENT_MOUSEUP event with the source as the canvas you entered. Then PostEvent it with the update flag as true so it would replace the event it would replace? I may have misunderstood how that event stuff works though.

Or maybe send a mouse up event as you leave one canvas and send a mousedown as you enter the new one so the program has focus in that one? Again I wouldn't have a clue how to do that (i tied but failed) and I may have again misunderstood how the events work.


ImaginaryHuman(Posted 2005) [#3]
Is it just me or is drag and drop extremely highly overrated? I hardly ever use it. It seems like a poor attempt to get two applications to share data in a very cumbersom manner, caused by the very fact that applications start out being so isolated from one another. What is really needed is a paradigm shift in the philosophy behind the degree of unity in the system.


Tom Darby(Posted 2005) [#4]
On Windows and Linux, drag and drop is indeed overrated. On OS X, though, it works surprisingly well...


REDi(Posted 2005) [#5]
What is really needed is a paradigm shift in the philosophy behind the degree of unity in the system

What's this, frigging StarTrek :)

Yeah, I rarely use drag and drop myself, but in this case its the best option.


bradford6(Posted 2005) [#6]
I want to be able to drag from my MAC to my Win32 (and then to my Linux Box. do i just need to connect the monitor to all 3 systems? maybe splice the wire?


sorry to drag-n- drop this topic :)


REDi(Posted 2005) [#7]
splice the wire?

You should give it a go, let us know how you get on :P


REDi(Posted 2005) [#8]
Well I've sorted both problems (with disablegadget then enablegadget again), but now the mouse pointer isn't changing when I tell it to. :(



REDi(Posted 2005) [#9]
*papa lazarou voice* It's okay I've fixed it now!


FFFT :)


WendellM(Posted 2005) [#10]
Nice. Funny how tricky things like that look so simple once they're worked out (but it's the working out that's the challenge!). That's going in my "Others' Source" folder. :)


BlackSp1der(Posted 2005) [#11]
your code have an error with the mouse pointer

grab in any canvas, go outside the window and release the mouse botton.
after that back to your window and push in the other canvas.


WendellM(Posted 2005) [#12]
^ I remember wrestling with that issue when doing panels as image buttons. It's only a problem if the user changes his mind half-way through, but it needs to be handled in case he does. I had to keep track of two states separately: "mouse over" and "primed" (the mouse button has been pressed down but hasn't yet been let up). There are different outcomes when EVENT_MOUSEUP occurs depending on the current value of those two states, and they change depending on what the user does with the mouse pointer and button.

I ended up cheating and using the panel's Text field as a way of storing those two states rather than creating a proper "TApplet"-sort of type... which I probably should go back and do with a rewrite for 1.14 (especially since 1.14 changed handle requirements with Strict and today's synchmods fixed the shadow panel problem on the Mac).


REDi(Posted 2005) [#13]
argh cr#p, I'm not sure if I can get around that without getting OS specific, errrmm...

*EDIT*
Dodgy workaround...

It would be nice to get EVENT_MOUSELEAVE events for windows, then I could just cancel the drag'n'drop stuff out when the mouse leaves the window. oh well that'll do for now.


WendellM(Posted 2005) [#14]
^ Seems to work well enough with a quick look, though I see what you mean if the user drops outside the Blitz window. I haven't messed with EVENT_MOUSELEAVE for whole windows. If I ever use it, I'll sic (my self-imposed) "picky police" on it to see if it can be made perfectly "regular" (and share it here).

It's a pain, ain't it: having to deal with changing one's mind in the middle of a drag-n-drop. Ah, well, that's life... Users have no idea how complex those little gadgets are in order to allow that, and they don't need to... :) But, it's really professional when done just right.


BlackSp1der(Posted 2005) [#15]



REDi(Posted 2005) [#16]
Nice one Sp1der, the problem with that is we don't get ENTER/LEAVE events for other gadgets like buttons, so if the pointer goes over a button the drag and drop is cancelled :(



and for some reason it doesn't alway work on my system, especially if I move the mouse out the window really fast it doesn't always get the leave event. (is that a bug?)