dragData in onDragStart() returning true/false/nil
Discussion came up on the discord channel and it was mentioned that one could "edit" the drag data instead of having to fill in the rest (and keep what would normally be there). I tested myself and was unable to get this to work and Moon requested I post it here for later discussions.
Code:
<template name="link_audiostop">
<linkcontrol name="audioshortcut">
<script>
function onDragStart(button, x, y, draginfo)
local node = window.getDatabaseNode();
draginfo.setDescription(DB.getValue(node,"name","") .. " [stop]");
return nil;
end
</script>
<class>urlaudiostop</class>
<icon normal="link_audio" pressed="link_audio_down" empty="button_link_empty" />
</linkcontrol>
</template>
I couldn't get the "nil" return value to change the description using the above method. This is what I have that is working for now. This fills in ALL the data since the datainfo value is empty on start.
Code:
<template name="link_audiostop">
<linkcontrol name="audioshortcut">
<script>
function onDragStart(button, x, y, draginfo)
local node = window.getDatabaseNode();
draginfo.setDescription(DB.getValue(node,"name","") .. " [stop]");
draginfo.setShortcutData("urlaudiostop",node.getPath())
draginfo.setIcon("link_audio");
draginfo.setType("shortcut");
return true;
end
</script>
<class>urlaudiostop</class>
<icon normal="link_audio" pressed="link_audio_down" empty="button_link_empty" />
</linkcontrol>
</template>