PDA

View Full Version : Dragdata for tokencontrol has no persistance



Ken L
June 1st, 2018, 20:16
It seems the dragdata for tokencontrols for the onDragStart and onDragEnd has no persistence. If I add slots to the onDragStart's dragdata, it does not persist in either the on onDrop of the target or the return invocation of onDragEnd. In fact the reference is different from onDragStart and onDragEnd. OnDrop returns the same dragdata instance to the onDragEnd, but between onDragStart and onDrop, the instance is either regenerated, or outright replaced. If replaced, it runs counter to the dragdata's purpose in onDragStart as no matter what I put in the dragdata, it is erased. I'd kinda expect at least a merge rather than a wipe-and-replace.

This may be true for other 'supported' dragdata types such as windowreferences or what not.





Runtime Notice: s'ON DRAG START'
Runtime Notice: s'DIAGNOSTICS : dumpDragData + + + + + +'
Runtime Notice: s'dragdata instanceuserdata: 1706E5B0'
Runtime Notice: s'slot count: 2'
Runtime Notice: s'type: none'
Runtime Notice: s'dbnode: nil'
Runtime Notice: s'description: '
Runtime Notice: s'secret: false'
Runtime Notice: s'shortcut list: table: 15C41E48'
Runtime Notice: s'===== slot ( 1 )'
Runtime Notice: s'slot type: '
Runtime Notice: s'meta data: '
Runtime Notice: s' ---- '
Runtime Notice: s'custom data: nil'
Runtime Notice: s'number data: 0'
Runtime Notice: s'string data: '
Runtime Notice: s'shortcut data: nil'
Runtime Notice: s'die list: nil'
Runtime Notice: s'token data: nil ref: nil'
Runtime Notice: s'===== slot ( 2 )'
Runtime Notice: s'slot type: '
Runtime Notice: s'meta data: '
Runtime Notice: s' ---- '
Runtime Notice: s'custom data: combattracker.list.id-00013'
Runtime Notice: s'number data: 0'
Runtime Notice: s'string data: '
Runtime Notice: s'shortcut data: nil'
Runtime Notice: s'die list: nil'
Runtime Notice: s'token data: nil ref: nil'
Runtime Notice: s'DIAGNOSTICS : dumpDragData - - - - - -'


Runtime Notice: s'ctentry windowinstance onDrop -- type: token'
Runtime Notice: s'DIAGNOSTICS : dumpDragData + + + + + +'
Runtime Notice: s'dragdata instanceuserdata: 2484F4C0'
Runtime Notice: s'slot count: 1'
Runtime Notice: s'type: token'
Runtime Notice: s'dbnode: nil'
Runtime Notice: s'description: '
Runtime Notice: s'secret: false'
Runtime Notice: s'shortcut list: table: 2BE016A8'
Runtime Notice: s'===== slot ( 1 )'
Runtime Notice: s'slot type: '
Runtime Notice: s'meta data: '
Runtime Notice: s' ---- '
Runtime Notice: s'custom data: nil'
Runtime Notice: s'number data: 0'
Runtime Notice: s'string data: '
Runtime Notice: s'shortcut data: nil'
Runtime Notice: s'die list: nil'
Runtime Notice: s'token data: tokens/host/unsorted/ancient_occult_dragon.png ref: nil'
Runtime Notice: s'DIAGNOSTICS : dumpDragData - - - - - -'


Runtime Notice: s'ON DRAG END'
Runtime Notice: s'DIAGNOSTICS : dumpDragData + + + + + +'
Runtime Notice: s'dragdata instanceuserdata: 2484F4C0'
Runtime Notice: s'slot count: 1'
Runtime Notice: s'type: token'
Runtime Notice: s'dbnode: nil'
Runtime Notice: s'description: '
Runtime Notice: s'secret: false'
Runtime Notice: s'shortcut list: table: 19F6F150'
Runtime Notice: s'===== slot ( 1 )'
Runtime Notice: s'slot type: '
Runtime Notice: s'meta data: '
Runtime Notice: s' ---- '
Runtime Notice: s'custom data: nil'
Runtime Notice: s'number data: 0'
Runtime Notice: s'string data: '
Runtime Notice: s'shortcut data: nil'
Runtime Notice: s'die list: nil'
Runtime Notice: s'token data: tokens/host/unsorted/ancient_occult_dragon.png ref: nil'
Runtime Notice: s'DIAGNOSTICS : dumpDragData - - - - - -'

Moon Wizard
June 1st, 2018, 21:31
All window controls use exactly the same code for onDragStart and onDragEnd event handling. (except for minor variations in chat window only)

Make sure that you return true to indicate that you are overriding the drag data object in your handler. Otherwise, the default control handling will replace. There is no merging.

Regards,
JPG

Ken L
June 1st, 2018, 21:59
That's the thing.. if you stop the default behavior for onDragStart, both the onDrop and onDragEnd methods receive a nil dragdata, it doesn't even bother sending the customized dragdata.

You're not even allowed to return your dragdata as it only specifies a boolean return, so you can only trust that the passed reference is reused.

Moon Wizard
June 1st, 2018, 22:50
You have to modify the drag data object being passed in, then return true.
If you just return true without modifying the dragdata parameter object, then the drag object gets cleared.

Regards,
JPG

Ken L
June 1st, 2018, 23:01
I've done just that by adding a slot + customdata.

edit: I didn't assign the type for it to follow through, it works as expected now.