celestian
June 24th, 2019, 06:39
I am attempting to use createControl to create a link button that will open a class/record I setValue() on the control.
Here is the template I use.
<template name="link_inventory_item_ct">
<linkcontrol>
<script>
function onDragStart(button, x, y, draginfo)
local sClass, sRecord = getValue();
local node = DB.findNode(sRecord);
if node then
local sName = DB.getValue(node,"name","");
local sPathToItem = node.getPath();
draginfo.setType("shortcut");
draginfo.setShortcutData( sClass, sRecord );
draginfo.setDescription(sName);
draginfo.setIcon("button_link_down");
return true;
end
end
function onButtonPress()
local sClass, sRecord = getValue();
if sClass and sRecord then
local sPathToItem = node.getPath();
Interface.openWindow(sClass, sRecord);
return true;
end
end
</script>
<anchored >
<top />
<left />
</anchored>
<icon normal="button_link" pressed="button_link_down" empty="button_link_empty" />
</linkcontrol>
</template>
Here is the lua I use to create the control object.
local controlItemLink = createControl("link_inventory_item_ct", sControlItemLink);
controlItemLink.setAnchor("top", sControlItemName,"top","absolute",10);
controlItemLink.setAnchor("left", sControlItemName,"right","absolute",0);
controlItemLink.setAnchor("right", sControlItemName,"right","absolute",-20);
controlItemLink.setValue('item',nodeItem.getPath() );
However, the button/link doesn't seem to allow interaction at all. Neither drag or mouse clicks on them work.
The result of my code is something like this. (I also createControl for the count and name of the items)
https://i.imgur.com/O8L0IuH.png
This item list is generated from a single string, not a list of nodes. My use case is to eliminate the inventorylist objects on npcs while in the CT but also be able to "see" the items and link back to the source NPC record that it came from. So far all this works it's just I can't seem to get the link buttons to interact.
Here is the template I use.
<template name="link_inventory_item_ct">
<linkcontrol>
<script>
function onDragStart(button, x, y, draginfo)
local sClass, sRecord = getValue();
local node = DB.findNode(sRecord);
if node then
local sName = DB.getValue(node,"name","");
local sPathToItem = node.getPath();
draginfo.setType("shortcut");
draginfo.setShortcutData( sClass, sRecord );
draginfo.setDescription(sName);
draginfo.setIcon("button_link_down");
return true;
end
end
function onButtonPress()
local sClass, sRecord = getValue();
if sClass and sRecord then
local sPathToItem = node.getPath();
Interface.openWindow(sClass, sRecord);
return true;
end
end
</script>
<anchored >
<top />
<left />
</anchored>
<icon normal="button_link" pressed="button_link_down" empty="button_link_empty" />
</linkcontrol>
</template>
Here is the lua I use to create the control object.
local controlItemLink = createControl("link_inventory_item_ct", sControlItemLink);
controlItemLink.setAnchor("top", sControlItemName,"top","absolute",10);
controlItemLink.setAnchor("left", sControlItemName,"right","absolute",0);
controlItemLink.setAnchor("right", sControlItemName,"right","absolute",-20);
controlItemLink.setValue('item',nodeItem.getPath() );
However, the button/link doesn't seem to allow interaction at all. Neither drag or mouse clicks on them work.
The result of my code is something like this. (I also createControl for the count and name of the items)
https://i.imgur.com/O8L0IuH.png
This item list is generated from a single string, not a list of nodes. My use case is to eliminate the inventorylist objects on npcs while in the CT but also be able to "see" the items and link back to the source NPC record that it came from. So far all this works it's just I can't seem to get the link buttons to interact.