Drag item inside or out of listbox?

BlitzMax Forums/MaxGUI Module/Drag item inside or out of listbox?

Grisu(Posted 2014) [#1]
Hello everyone!

Is there a way to drag & drop listbox items inside a listbox, from one listbox to another or on a canvas via mouse? (Windows only)

I've put up a basic setup example below...

Icon strip (use as "icons.png"):


Code:


I'd like to visually move an item between listbox 1 <-> 2, inside each listbox or drag it onto a canvas.

Thanks
Grisu


Derron(Posted 2014) [#2]
I do not know if "maxgui" handles drag n drop somewhere (cannot remember to have seen that).

So I assume you will have to "code" it on your own:

- onmousedown on a list entry you store that entry
- if the mouse moves out of the gadgets area without "mouse release" you start a "drag"-action (or if the mouse moves > X distance)
-> create a temporary widget "attached" to the mouse position (move it with the mouse), also add the needed data (text, linked data block ...)
- if the mouse enters the other list, you ask the gadget if it accepts "drops", if yes, you might eg. recolor it or add a border or ...
- if the mouse gets released over that gadget, you start the "drop"-action
-> add the wanted data (text, data block) to the list entry and remove the temporary widget/gadget


Above just simulates DragNDrop, it could get extended to allow multiple widgets, to send out specific events (onDrag, onDrop, ...) but yay, this should be all you need.


bye
Ron