What a drag


#1

Trying to do Drag n Drop here. Bloody things throwing an exception ( on a dynamic_cast in DragAndDropContainer::findTarget ) while it’s still over the object i’m trying to drag.

Does everything that might possibly be dragged over have to be a target?

Shouldn’t the dynamic_cast just return 0 instead of blowing up?

if I drag fearsome quick, it does not throw (sometimes), but my drag image gets stuck half way between source and my pointer and won’t move.

drop operation does not complete.


#2

I’d only expect a dynamic_cast to crash if the object you’re passing it is a dangling pointer…


#3

Update.

The object causing the trouble was from a wee library of mine which didn’t have RTTI switched on. No more exceptions.

Now I still can’t get the dragImage to stop sticking solid on it’s way to the target. Sometimes if I really whip it accross my target will get its isInterestedInDragSource() called (twice?) then itemdragenter() gets called. Now when I release itemDropped does NOT get called.


#4

If it gets stuck, that could be because you’re deleting the component that was receiving the mouse drag messages?


#5

still no joy. even tried creating a component specially for the dragComponent.

I’m trying to drag from a listbox. does that bring anything to mind? I seem to remember it working when I was using a simplelistbox.

this is twisting my melon.


#6

Stick a breakpoint in the destructor of the component that’s receiving the mouseDrag callbacks. I bet it gets deleted.


#7

nope. doesn’t appear to be the case.


#8

DragImageComponent::mouseDrag() is NOT being called if thats any help. Is something eating my mouseevents?

Had a breakpoint in there and tested drag on another component. drag worked and DragImageComponent::mouseDrag() called.

?


#9

When the drag begins, the drag manager registers itself as a mouselistener on the source component passed into DragAndDropContainer::startDragging - so if that comp stops getting drags, the drag will also stop. It could stop because it’s deleted, made invisible, etc.

do a breakpoint in DragAndDropContainer::startDragging and see what that source component is, then find out when it gets zapped.


#10

Nope, can’t find anything getting deleted!

Have you (or anyone) ever done drag n drop from a listbox?


#11

barfled.

just when I think I’m getting good, I go get barfled.

here’s the script

ListBox
creates/uses MyRowComponent

MyRowComponent
composite of 2 components

  1. MyHighlyGraphicalComponent
  2. Label

I first of all had the ListBox handling mouseDrag and calling startDragging. It was creating an image of all selected rows as dragImage and using entire ListBox as dragComponent (it knows how to drop all its selected items on the target.

pish, gets stuck 1/2 inch max from start pos.

tried creating a special container class to use as dragComponent (trying allsorts here)

same pish.

moved mouseDrag into MyRowComponent with “this” as dragComponent.

same pish.

then tried the mouseDrag/startDragging in my MyHighlyGraphicalComponent.

drags beatifully! even from the ListBox.

I can easily modify MyHighlyGraphicalComponent to have it’s own label but MyRowComponent has some funtionality that would be well out of place in MyHighlyGraphicalComponent but extremely usefull for dropping!

hmmm.

I’ll forget trying to drag MyRowComponents for the minute and have a rethink.


#12

Could it be that the Label comp is picking up the mouse click and using it to activate its text editor? That’d mess around with the component hierarchy and might stop the drag.


#13

Don’t think so. The labels just a strip at the bottom.

I got desired functionality giving the dropTarget a pointer to the list. when a drop happens it asks the list for all selected rows which works fine.

Now this is the kludgy bit… I added a setAsMemberOfAList( ListBox* ) to the graphical component. so when it’s dragged it can ask the listbox for row components and create a composite image using snapshots.

Not how I originally planned things!


#14

I would like to know what was going wrong, though. Maybe it’s because your rows are getting selected when you do the mouse-down, and the selection change calls your updateRowComponent, which does something to change the comp hierarchy?


#15

so would I!

I was suspecting that the listbox was maybe doing a shuffle of some description.

have you done a drag enabled listbox? if not and you get a minute maybe you could fling a wee test together? I’d like to isolate the problem, make sure it’s my duff code!

buggeration debugging a mousedrag is a drag so to speak. as soon as debugger kicks in you lose your drag operation!


#16

No, I don’t think I have ever done a dragged list. I’ll have a go. Might be possible to tweak the dragger classes to cope with components getting reshuffled.


#17

[quote=“Karbon L. Forms”]
I’m trying to drag from a listbox. does that bring anything to mind? I seem to remember it working when I was using a simplelistbox.

this is twisting my melon.[/quote]

I’m trying to face the same problem Karbon.
I need a ListBox that shows a list of file names (wav files). The user may be able to drag a single row over a cell target.

I can’t understand how doing this with ListBox.
I’ve done it before using SimpleListBox, but in this manner I can’t implement the drag function, or not?

Here is a sample of my custom list box

[code]class IrListBox : public ListBox
{

public:
IrListBox(){}
~IrListBox(){}

OwnedArray<File>	irList;

int getNumRows()					{	return irList.size();	}
Component* createRowComponent  ()	{	return new IrListRowComponent();	}
void updateRowComponent (Component* rowComponent,int rowNumber,bool isSelected);

};[/code]

Using findChildFiles I fill irList and then I need to fill the list box.
How?

thanx a lot

bye


#18

yo.

my listbox can be re-ordered by drag n drop. I can select discontigious items and drag them to, say the top of the list for example. And there is another (slighly different) listbox from which contains a “construction kit” for building the main list.

Is this what your after cialz?

I’m not at work so can’t see my code right now, but I can tell you for sure that it’s held together with gaffer tape and chewing gum, and I’m not touching it until Big J does an update!!

All based on the listboxitem component being a container for the comp that is really dragged therefor bypassing whatever black magic the listbox does to it’s pointer list.


#19

I’ve got some nice stuff ready for this in the next release, which I’m hoping to get out within a few days as long as it all seems stable. I’ve not thought about re-ordering lists, which is a bit tricky, but might add that in future.


#20