dragdrop shennenegins

Nn0qtrnL1/8/2022
Right now, a user can drag a spell onto their character sheet. I store that in a 'spell' array and list it in the 'spell library'. They can prep the spell with the UI and that (for now) sets a flag which causes it to be displayed under the 'prepared spells' side as well. Ideally, I'd like a user to drag the spell from the library side to the prepped side and achieve the same thing. I don't need a solution and I haven't started trying to do this, but I'd really appreciate if someone could simply drop me a hint. A key word or function to look into to make this happen, because right now my understanding of how items get embedded into actors after dragging them onto the sheet is, "A wizard foundry did it."
CCalego1/8/2022
the key word hint is dragDrop
CCalego1/8/2022
more details are that somewhere in ActorSheet, there's a dragDrop registration which handles Item droppage.

You'll want to modify that logic to see what element the item is dropped into and thus change what happens
Nn0qtrnL1/8/2022
Somehow, in spite of me looking, I managed to not find this function. *facepalm*
Nn0qtrnL1/8/2022
Thanks. That should be enough for me to get into all sorts of stupid trouble!
CCalego1/8/2022
these are the docs for DragDrop itself, but they're not super helpful:
https://foundryvtt.com/api/DragDrop.html

Core puts some fluff around this automatically for ActorSheet, providing these methods:
_onDrop, and more interestingly _onDropItem

I can't find these in the docs actually, seems they're marked Private, but a system is definitely expected to override them.
CCalego1/8/2022
@CSwendrowski check me on that 'definitely' when you get a chance pretty please.
Nn0qtrnL1/8/2022
I see. I mean, that looks usable after some experimentation. Famous last words, though.
Nn0qtrnL1/8/2022
I just noticed this in testing almost immediately. One of my players messed up his spell order because he instinctively wanted to drag his spells over to the 'prepped' section, so this should be a thing.
MMana1/8/2022
Default behaviour for drag&dropping an item on same sheet is to sort them. You may want to override that some when they aren't dropped into same section.