DragAndDropContainer


#1

There seems to be some instability in the dragging code. It’s doesn’t quite do what I want, so I’m tracking along with the object, using a blank object. My dragging object is right on the mouse. The built-in source bounces all over the place, almost as if it is trying to have physics? It’s hard to even hit a small target, it’s so jumpy.

I’m not doing anything funny, just startdragging()

Bruce


#2

I’ve never had problems with it - does the juce demo’s dragging page work ok for you? If so, what are you doing differently?


#3

Probably that other object that I’m tracking. Looking at the dragcontainer code, it looks like it often checks what cursor is under the mouse, instead of remembering what it was dragging. The obvious assumption is that the drag surrogate is there.

Since I’m also dragging along another object, it sometimes probably gets the wrong answer.

But obviously, I’m engaged in a horrendous bodge. I had to get something out last night. What’s really missing, for me, is a dragging event that I can respond to (in dragcontainer). It’s notable to me that Jucer doesn’t use this system because it needs to do more.

So I’d like to request that extra, optional methods get added so we can track a drag. In my case, I’m drawing a connection from a fixed point to the cursor, and trying to snap it to a target if there is one.

Maybe you could just point to where that event should get fired?

Bruce


#4

Sounds like a bodge and a half. Doesn’t DragAndDropTarget::itemDragMove give you enough info?


#5

Yes, bodgy bodgy bodge, to be exact. Promised a version with a start on a feature.

Not unless I start making fake drop targets to cover everything else - which I could do, I suppose. It would mean making my d&dcontainer also a target and track that way.

Don’t you think that some other methods are needed? It seems that throughout Jucer it didn’t meet your needs either.

What do you think?

Bruce


#6

In case you’re curious:


#7

Looks cool.

The drag and drop stuff really isn’t intended for that kind of specialised interaction - it’s just meant for old-fashioned dragging and dropping of discrete things like files. Not sure which bit of the jucer you’re referring to, but I can’t think of anything in there where having a more flexible drag+drop would have helped.


#8

No, I can see that it’s unusual. I went to d&dcontainer so I could get the drop target without crunching all the positions to see what component I’m over.

The ‘Component at mouse’ static method doesn’t help since I’m dragging a component around right on the mouse, and I don’t see a component at (mouse +/i x) or a way to get all components under the mouse, in z order, and going though all the components to check would be cheesy.

What do you recommend? Could a dragMouse event be added to d&dcontainer? Is there a better component at mouse position trick?

Bruce


#9

You could look in d+dcontainer for the best trick for finding the component that you’re over. I’ll have a think about adding some feedback to the container, maybe a virtual method that you could override.


#10