I'd take a look at these two. Be aware they may be protected functions despite not being labeled as such.
PickupSpell()
PlaceAction()
Note: The Pickup/Place functions are what facilitate the drag-and-drop system and as such manipulate what's being held by the cursor.
You may want to call
ClearCursor() first to make sure it isn't holding anything if you wish to do this in code.