[FREE] DragAndDropAlt - Another extension for drag and drop components on the screen

Another extension for drag and drop components on the screen.

Thanks to @DanBadea for sponsor this extension.

FUNCTIONS

image
Set the component droppable or not.
Only a container (layout/arrangement) can be set to droppable

image
Set the component draggable or not.

image
Move a component to a new target(container) with specified index.
or move the component in same container (re-order the components)
if index set to 0, that will move the component to the end of the container.

EVENTS

image
When a component is start to dragged.

image
When a component is dragged into a target (droppable container). this target can be same with component's parent, or not.

image
When a component is dragged and the location changed.
index means the order of the component ( which the dragged component is hovering on) in the target, or 0 if the dragged component is hovering on nothing.

image
When the component is dragged leaving the target container.

image
When the component is dropped on the target container.
We normally add blocks here to really move the component.

image
When this drag and drop completed.

DOWNLOAD

cn.kevinkun.DragAndDropAlt.aix (10.0 KB)
DEMO AIA - dada (1).aia (91.1 KB)

9 Likes

Differences, advantages compared to this one...

Thank you Kevin for your time and your work. The "sponsoring" is the less important fact in the extension development. So... I have no merit at all.

This extension solves the huge problem that the original DragAndDrop has. The crashing of the app and discovering a way to avoid that crash!!!

The guilt behind that crash is this control from the original DragAndDrop.

component_event

When the component that came on "tagData" achieves the event "DropCompleted" nothing more can be done, it creates a paradox and the app crashes.

@Kevinkun was genial (as always) and created a lot of component_events.

component_event (1)

component_event (2)

component_event (3)

component_event (4)

component_event (5)

component_event (6)

All the above is a wonderful job.

Let's speak about which of these controls solves the app crashing problem. That control is when DragAndDropAl1.Drop.

component_event (5)

More exactly in the below approach.

This control, when DragAndDrop1.Drop catch the dropping path of the "component" before the drop is complete!!! And can be conditioned that if wants to drop on itself (create a paradox) don't do that, don't drop... do nothing.

This must be added to the original DragAndDrop extension, it is the most important thing.

2 Likes

The huge advantage (from my point of view) is the fact that a dragged component is caught by the arrangement where is dropped, and it slides on them when drag.complete!!! This behavior lets us (me) create arrangements dynamically one on another on another on another... and so on.

DragAndDropDynComp.aia (103.5 KB)

Give it please a run to the above aia, to understand what I mean.

Repositioning Tool Extensions is another "must have extension" but has nothing to do with Drag And Drop, it doesn't Drop, it only moves a component! Or I don't discover the "Drop" functionality.

As @Ken does not make the DragAndDrop extension open source, I don't know if, from an ethical point of view, somebody else can add this control to his extension. :sob:

Ah ok (I didn't test it), so something like this:

Thank you very much, Anke, This one I don't see it. Thank you again. I will test it. I searched for all that I could find for Drag and Drop, all that recommended me on another thread Taifun, and so on, but that one, I didn't see it. Another example is that I can be blind... sometimes.

Meanwhile, I have a different approach (different approach vs @Kevinkun on his first post).

DragAndDropAlt_test_1.aia (78.6 KB)

The truth is that it crashes one time with a "stack overflow" error, but it is possible that is my fault, I will continue with this test.

Anyway, congratulations @Kevinkun for this work, it is possible that it will be the best Drag-and-drop extension for AI2.

Thank you again, Kevin.

1 Like

After half a day, the second test was a new approach.

DragAndDropAlt_test_2.aia (80.2 KB)

I have two blocks that don't work as expected, the color of borders and round corners from DragAndDropAlt1.DragEntered, but this will be in the chapter "fine-tuning". Anyway in the same chapter, I must redesignate some procedures to reuse blocks as they are repetitive.

It is possible to serve somebody as inspiration.

Above... I write half day?! I remember that to understand CompCreator it took me a month. Some progress exists but not enough.

@Kevinkun , what can I say... On my scale of 11 stars, I can evaluate this extension with only 10 stars because it doesn't come with a method to understand it in 10 minutes. I'm joking about the 10 minutes... :innocent:

Congratulations on this extension, on the original one, it was many gentleman's who asked for those controls. after four years it has them. The best later than never.

Thank you again, Kevin.

Edited... I randomly created more than 100 arrangements and I was wondering why the app doesn't crash. Well... I catch all the arrangements, I drag them all, and I let them drop on himself. It crash!!! Of course, in real life, those things don't happen. I push things... But over the limits. That crash I bet that it was the Android that went to sleep.

if you want to know what happened, just use logcat

Taifun

Thank you again for this link, last time when I had a problem with the DragAndDrop original, you sent me the same link. I go and study a little of them. I swear that only terminals, cmd's, and USB cables for 3 devices that give the same error I can't. I use enough the terminal on the CPM86 Concurrent times... After that, I become... lazy... I become a windows guy (OS independent but give me some windows and a mouse).

When a problem arrives, the important fact is the solution not what is used to solve it.. The problem was solved with only intuition and some logic. I'm happy that I can create the paradox that the original extension creates. Anyway, the problems with crashes are solved with the new DragAndDropAlt extension just created by Kevin.

Thank you again Taifun.

Back with another implementation of DragAndDropAlt, this time among DynamicComponents. BTW... The above approach DragAndDropAlt among CompCreator , randomly doesn't create red or blue squares, I'm almost sure that on the logic I use, something randomly fails. I must revise/rethink the logic.

So... the .aia.
DragAndDropDynComp.aia (116.5 KB)

The blocks, I hide the decoration, to easily follow the logic.

The result is that I don't understand it.

As you can see in my last image, I generated some blue and red squares, first I moved them from the arrangement where I created them to the arrangement where I work with them, and I deleted them all.

As you can see on the image of the blocks, I have two labels where I look at what's happening on two arrangements, HorizontalArrangement1 (work arrangement) and HorrizontalArrangement3 (create arrangement). On the HorizontalArrangement3 I generate dynamic red and blue squares and move them on the HorizontalArrangement1. If I want or need to delete them, I move them to HorizontalArrangement4 to delete them. This is the basic logic.

Well... if you look at the last image, from a visual point of view on Companion, I have only two squares, one red and one blue on the HorzontalArrangement3 (where I created them).

@Kevinkun Even if I move all red/blue squares on the HorizontalArrangement1 (the work arrangement), the HorizontalArrangement1 remains empty (Label1). All the arrangements remain on HorizontalArrangement3, where I created them, not where I moved them.

Even if I delete them all, at the visual level, they are deleted, but they remain all, in the create arrangement, on the HorizontalArrangement3 (they all are not deleted). This is about what I debated with @TIMAI2 on another thread.

So... something without logic from what I want, and what's really happening.

Thank you all.

DragAndDrop among CompCreator.

The .aia
DragAndDropAltCompCreator.aia (116.3 KB)
The blocks (same logic above but with CompCreator)

@TIMAI2 You were right, the CompCreator really deleted the deleted arrangement!!! The DynamicComponents doesn't really delete the deleted components, only it hides them!!! One important thing to save in my memory!

But... Still, DragAndDropAlt doesn't move them, only generates a "ghost" copy of them and hides them on the arrangement where they were created. :exploding_head:

after DragAndDrop. moveComponent , the compcreator. children is not functional. i remember i already told you that.

and also, DO NOT use compcreator and dynamiccomponent mixed up.