ListBox, handling mouse clicks with object

Hi, I have a listbox made from objects (with another children objects inside). Can it handle the mouse clicks and drag and drop? How? is there any easy way?

I’ve tried with listBoxItemClicked and getDragSourceDescription but they don’t work because I’m clicking on an object!

If you’re using custom components then you’d need to do the drag/drop handling yourself. It’s not a big deal though, you just need to overload mouseDrag() and make it start the drag operation. Grep for DragAndDropContainer::startDragging and there should be plenty of example code knocking around…

I wanted handle the row selections, I have no idea about how could i do it (since listBoxItemClicked would need use a method from the ListBox class), any clue here please?

Again, you’d just need to make your component handle the mouseDown() and use that even to select the row.

om, ok thx you. I thought it would be more complex :slight_smile:

Yes, it’s a bit of a PITA to do custom rows, I’m afraid.

Again, you'd just need to make your component handle the mouseDown() and use that even to select the row.

Hello! Tell me please, how to select the row with overloading the mouseDown() of the custom component? I can't understand, how to select the row which is a custom component.

Thanks in advance for help ;)

Don't get me wrong, the forums are great for asking questions and getting help, but the Demo project that's in the Examples folder is a really solid base for showing how to use the widgets.

There's a Widgets demo, and it looks like the Drag & Drop tab has a ListBox in there.

Yes, I watched this demo many times, but it's maded from normal rows, not custom components. And I've tried different implementations of selecting rows (which are custom components) without success.

And I have a one more question. For example I have class ierarchy like this:

GlobalComponent, ComponentWithListBoxes, CustomListBox, CustomListBoxModel, CustomRowComponent.

The question is: to make the oppotunity the text from CustomRowComponent dragged (as source) to another component of GlobalComponent, which of these classes should inherit from DragAndDropContainer? Just a CustomRowComponent ? Or all of these classes?

 

Thanks;)

 

No, you definitely skimmed over the example: grep for "refreshComponentForCell" in WidgetsDemo.cpp in the Demo project!

DragAndDropContainer = source, DragAndDropTarget/FileDragAndDropTarget/TextDragAndDropTarget = well, the target.

The WidgetsDemo code has all of this.

I saw that example but it's  differents from that I'm talking about. I just need to know, how to select the row which a  custom component from the ListBox! About DragAndDropContainer my question was about if all classes in my hierarchy should inherit from DragAndDropContainer or just a custom component, which information is going to be dragged?