Drag and drop to list component

Perhaps you were correct?

This turned out to be a bit simpler than I was originally thinking. Not trivial, but not really painful either.

Add an extension function to your list component, I called mine addDropListener. Then in the script add the following script:

from java.awt.dnd import DropTargetAdapter, DropTarget
from com.inductiveautomation.ignition.client.tags.dnd import ListOfQualifiedPath
	
class customDragDropListener(DropTargetAdapter):
	_comp = None
	def __init__(self,comp):
		DropTargetAdapter.__init__(self)
		self._comp = comp
			
	def drop(self,e):
		e.acceptDrop(e.getDropAction())
		paths = [[path] for path in e.getTransferable().getTransferData(ListOfQualifiedPath.FLAVOR)]
		self._comp.data = system.dataset.addRows(self._comp.data,paths)
			
ddl = customDragDropListener(self)
DropTarget(self,ddl)

Then in the internalFrameActivated Event Handler on the window use the following script

NOTE: You will need to change the path for the component to be valid for your system.

tagList = system.gui.getParentWindow(event).getComponentForPath('Root Container.List')

if not tagList.getDropTarget():
    tagList.addDropListener()

Select any number of tags in the Tag Browse Tree component drop them on the list and they will be appended to the list's dataset. It doesn't validate incoming paths against pre-existing paths so you can add duplicates, if you want this functionality you'll need to add it to the drop function.

1 Like