psicodelix
July 27th, 2011, 10:21
Hi,
I have a windowlist wich item class has another windowlist (nested). Each windowlist accepts different drop classes, and the only handler for onDrop events is on the main windowlist. When I drop a main object into the list the handler works fine and the list creates a main item. However when I drop a secondary object the onDrop event fires twice, and 2 secondary items are created. That's the source code of the event:
function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
-- POWER
if draginfo.getShortcutData() == "referencepower" then
local sourcenode = draginfo.getDatabaseNode();
local newwin = NodeManager.createSafeWindow(self);
if newwin then
local newname = sourcenode.getChild("name").getValue();
local newvalue = sourcenode.getChild("action").getValue() .. ', ' .. sourcenode.getChild("descriptor").getValue();
newwin.name.setValue(newname);
newwin.value.setValue(newvalue);
newwin.shortcut.setValue(draginfo.getShortcutData( ));
end
return true;
end
-- FEAT
if draginfo.getShortcutData() == "referencefeat" then
local droptarget = getWindowAt(x, y);
if droptarget then
local sourcenode = draginfo.getDatabaseNode();
-- Create new entry based on entry in another level
local newwin = NodeManager.createSafeWindow(droptarget.powerfeats list);
if newwin then
newwin.name.setValue(sourcenode.getChild("name").getValue());
newwin.value.setValue(sourcenode.getChild("summary").getValue());
newwin.shortcut.setValue(draginfo.getShortcutData( ));
end
end
end
end
end
Any idea?
thank you very much.
I have a windowlist wich item class has another windowlist (nested). Each windowlist accepts different drop classes, and the only handler for onDrop events is on the main windowlist. When I drop a main object into the list the handler works fine and the list creates a main item. However when I drop a secondary object the onDrop event fires twice, and 2 secondary items are created. That's the source code of the event:
function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
-- POWER
if draginfo.getShortcutData() == "referencepower" then
local sourcenode = draginfo.getDatabaseNode();
local newwin = NodeManager.createSafeWindow(self);
if newwin then
local newname = sourcenode.getChild("name").getValue();
local newvalue = sourcenode.getChild("action").getValue() .. ', ' .. sourcenode.getChild("descriptor").getValue();
newwin.name.setValue(newname);
newwin.value.setValue(newvalue);
newwin.shortcut.setValue(draginfo.getShortcutData( ));
end
return true;
end
-- FEAT
if draginfo.getShortcutData() == "referencefeat" then
local droptarget = getWindowAt(x, y);
if droptarget then
local sourcenode = draginfo.getDatabaseNode();
-- Create new entry based on entry in another level
local newwin = NodeManager.createSafeWindow(droptarget.powerfeats list);
if newwin then
newwin.name.setValue(sourcenode.getChild("name").getValue());
newwin.value.setValue(sourcenode.getChild("summary").getValue());
newwin.shortcut.setValue(draginfo.getShortcutData( ));
end
end
end
end
end
Any idea?
thank you very much.