Improved Drag And Drop (07-2024 W2)


Among other UI-related things, I decided to redo the Djinn Menu so it handled drag-and-drop the same way another project of mine (Digital Craftsman) did. Of course, it took some doing… Flexalon didn’t have support for that built-in, and it had been a pretty long time since I first implemented this feature in Digital Craftsman ^^; Thankfully, I was able to use that project’s source as reference.

How Was It Pulled Off?

It was mainly with these 3 components:

  • Swappable
    • This signals when it gets clicked, dragged and such
  • SwappableManager
    • This responds to the above and handles the switcheroos
  • ControlLayoutsOnSwap
    • This makes it so that the layout-prep is disabled when entries are being dragged or swapped, and then enabled otherwise

When a swap or drag starts, the manager keeps track of the swappables’ original parents, positions, etc. It then uses that info to make sure that things get moved and parented to the right stuff. Another thing done at this time is reparenting the relevant entries’ transforms so they’re rendered above the rest of the UI.

And because why not, I made it so that the player can pull off the switcheroos through plain old clicking instead of drag-and-dropping. And just like with the batsys buttons, they change size based on whether or not they’re being hovered over.

What It Looks Like In Action

Looking Back...

It was a mistake for me to have this functionality handled mainly through visual scripting in DC… Not just because of how specific to that project the implementation was, but because of a lack of reusability. Maybe in the future, I’ll release this D&D system to the public.

Get Trigram Islands

Leave a comment

Log in with itch.io to leave a comment.