Oh - and is the GM removing the link or a player?
Printable View
Oh - and is the GM removing the link or a player?
In the table entry that Nickademus references the linkfield (resultlink) is hidden if there is no link to it (setVisible(false)) and set to visible if there is link data, this is done via the updateDisplay function. Perhaps you could do something like that? Of course, the main issue here is that there is no obvious link icon to drag a link to.
Code:<windowclass name="table_result">
<margins control="0,0,0,2" />
<script>
function onInit()
registerMenuItem(Interface.getString("table_menu_linkdelete"), "erase", 8);
updateDisplay();
end
function onMenuSelection(selection)
if selection == 8 then
resultlink.setValue();
end
end
function updateDisplay()
local bLink = not resultlink.isEmpty();
resultlink.setVisible(bLink);
end
function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
resultlink.setValue(draginfo.getShortcutData());
return true;
end
end
</script>
<sheetdata>
<genericcontrol name="leftanchor">
<bounds>0,2,0,20</bounds>
<disabled />
</genericcontrol>
<genericcontrol name="base">
<anchored position="over" />
<script>
function onDrop(x, y, draginfo)
return window.onDrop(x, y, draginfo);
end
</script>
</genericcontrol>
<link_tableresult name="resultlink">
<anchored>
<top offset="2" />
<left parent="leftanchor" anchor="right" relation="relative" offset="5" />
</anchored>
<invisible />
<script>
function onValueChanged()
window.updateDisplay();
end
function onDrop(x, y, draginfo)
return window.onDrop(x, y, draginfo);
end
</script>
</link_tableresult>
I just tried it on my machine, by modifying the table record to test setValue() specifically. It's working as expected.
Looking at your code again, I think the problem is that you do not have "return true" at the end of your onDrop function. What I think is happening is that the value is actually being cleared in your onDrop event handler. However, since there is no return value, FG continues to process the drop event normally, which means that the link gets set again by the built-in windowreferencefield code.
Regards,
JPG