<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[drag and drop between vanilla lists]]></title><description><![CDATA[<p dir="auto">dear vanilla experts,</p>
<p dir="auto">I’m trying to build a simple drag and drop interface using vanilla:</p>
<p dir="auto"><img src="/assets/uploads/files/1560268660758-screen-shot-2019-06-11-at-12.57.32.png" alt="Screen Shot 2019-06-11 at 12.57.32.png" class="img-responsive img-markdown" /></p>
<ul>
<li>the left column contains group names (dict keys), the right column contains list items</li>
<li>I would like to copy items into groups (dict values) by selecting them in the right column and dragging them on top of group names in the left column</li>
</ul>
<p dir="auto">is this possible?</p>
<p dir="auto">my current code is below. the dragging part seems to work, but the dragged items can’t be dropped on top of items in the other list.</p>
<pre><code class="language-python">from vanilla import *
from AppKit import NSDragOperationCopy

genericListPboardType = "genericListPboardType"

class DragAndDropListItemsDemo:

    weekdays = {
        'Mon' : [],
        'Tue' : [],
        'Wed' : [],
        'Thu' : [],
        'Fri' : [],
        'Sat' : [],
        'Sun' : [],
    }

    def __init__(self):
        self.w = Window((400, 200), 'drag &amp; drop demo')
        self.w.list1 = List((0, 0, 200, -0),
                list(self.weekdays.keys()),
                allowsMultipleSelection=True,
                selectionCallback=self.list1SelectionCallback,
                selfWindowDropSettings=dict(type=genericListPboardType,
                        allowDropOnRow=True,
                        allowDropBetweenRows=False,
                        operation=NSDragOperationCopy,
                        callback=self.selfDropCallback))
        self.w.list2 = List((200, 0, -0, -0),
                ['banana', 'apple', 'orange', 'melon'],
                dragSettings=dict(type=genericListPboardType,
                        allowDropOnRow=True,
                        allowDropBetweenRows=False,
                        callback=self.dragCallback))
        self.w.open()

    def list1SelectionCallback(self, sender):
        selection = sender.getSelection()
        selectionKeys = [day for i, day in enumerate(sender.get()) if i in selection]
        for k in selectionKeys:
            print(k, self.weekdays[k])

    def dragCallback(self, sender, indexes):
        print('dragging…', indexes)

    def selfDropCallback(self, sender, dropInfo):
        isProposal = dropInfo["isProposal"]
        if not isProposal:
            print('dropped!')
            return True
            
DragAndDropListItemsDemo()
</code></pre>
<p dir="auto">thanks in advance for any hints!</p>
]]></description><link>https://forum.robofont.com/topic/653/drag-and-drop-between-vanilla-lists</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 16:52:22 GMT</lastBuildDate><atom:link href="https://forum.robofont.com/topic/653.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 11 Jun 2019 16:26:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to drag and drop between vanilla lists on Tue, 11 Jun 2019 17:00:45 GMT]]></title><description><![CDATA[<p dir="auto">dear vanilla experts,</p>
<p dir="auto">I’m trying to build a simple drag and drop interface using vanilla:</p>
<p dir="auto"><img src="/assets/uploads/files/1560268660758-screen-shot-2019-06-11-at-12.57.32.png" alt="Screen Shot 2019-06-11 at 12.57.32.png" class="img-responsive img-markdown" /></p>
<ul>
<li>the left column contains group names (dict keys), the right column contains list items</li>
<li>I would like to copy items into groups (dict values) by selecting them in the right column and dragging them on top of group names in the left column</li>
</ul>
<p dir="auto">is this possible?</p>
<p dir="auto">my current code is below. the dragging part seems to work, but the dragged items can’t be dropped on top of items in the other list.</p>
<pre><code class="language-python">from vanilla import *
from AppKit import NSDragOperationCopy

genericListPboardType = "genericListPboardType"

class DragAndDropListItemsDemo:

    weekdays = {
        'Mon' : [],
        'Tue' : [],
        'Wed' : [],
        'Thu' : [],
        'Fri' : [],
        'Sat' : [],
        'Sun' : [],
    }

    def __init__(self):
        self.w = Window((400, 200), 'drag &amp; drop demo')
        self.w.list1 = List((0, 0, 200, -0),
                list(self.weekdays.keys()),
                allowsMultipleSelection=True,
                selectionCallback=self.list1SelectionCallback,
                selfWindowDropSettings=dict(type=genericListPboardType,
                        allowDropOnRow=True,
                        allowDropBetweenRows=False,
                        operation=NSDragOperationCopy,
                        callback=self.selfDropCallback))
        self.w.list2 = List((200, 0, -0, -0),
                ['banana', 'apple', 'orange', 'melon'],
                dragSettings=dict(type=genericListPboardType,
                        allowDropOnRow=True,
                        allowDropBetweenRows=False,
                        callback=self.dragCallback))
        self.w.open()

    def list1SelectionCallback(self, sender):
        selection = sender.getSelection()
        selectionKeys = [day for i, day in enumerate(sender.get()) if i in selection]
        for k in selectionKeys:
            print(k, self.weekdays[k])

    def dragCallback(self, sender, indexes):
        print('dragging…', indexes)

    def selfDropCallback(self, sender, dropInfo):
        isProposal = dropInfo["isProposal"]
        if not isProposal:
            print('dropped!')
            return True
            
DragAndDropListItemsDemo()
</code></pre>
<p dir="auto">thanks in advance for any hints!</p>
]]></description><link>https://forum.robofont.com/post/2422</link><guid isPermaLink="true">https://forum.robofont.com/post/2422</guid><dc:creator><![CDATA[gferreira]]></dc:creator><pubDate>Tue, 11 Jun 2019 17:00:45 GMT</pubDate></item><item><title><![CDATA[Reply to drag and drop between vanilla lists on Thu, 13 Jun 2019 11:18:48 GMT]]></title><description><![CDATA[<p dir="auto">Something like this?</p>
<pre><code>from vanilla import *
from AppKit import NSDragOperationCopy

genericListPboardType = "genericListPboardType"

class DragAndDropListItemsDemo:

    weekdays = {
        'Mon' : [],
        'Tue' : [],
        'Wed' : [],
        'Thu' : [],
        'Fri' : [],
        'Sat' : [],
        'Sun' : [],
    }

    def __init__(self):
        self.w = Window((400, 200), 'drag &amp; drop demo')
        self.w.list1 = List((0, 0, 200, -0),
                list(self.weekdays.keys()),
                allowsMultipleSelection=True,
                selectionCallback=self.list1SelectionCallback,
                selfWindowDropSettings=dict(type=genericListPboardType,
                        allowDropOnRow=True,
                        allowDropBetweenRows=False,
                        operation=NSDragOperationCopy,
                        callback=self.selfDropCallback))
        self.w.list2 = List((200, 0, -0, -0),
                ['banana', 'apple', 'orange', 'melon'],
                dragSettings=dict(type=genericListPboardType,
                        allowDropOnRow=True,
                        allowDropBetweenRows=False,
                        callback=self.dragCallback))
        self.w.open()

    def list1SelectionCallback(self, sender):
        selection = sender.getSelection()
        selectionKeys = [day for i, day in enumerate(sender.get()) if i in selection]
        for k in selectionKeys:
            print(k, self.weekdays[k])

    def dragCallback(self, sender, indexes):
        # print('dragging…', indexes)
        self.draggedItems = [self.w.list2.get()[i] for i in indexes]

    def selfDropCallback(self, sender, dropInfo):
        isProposal = dropInfo["isProposal"]
        if not isProposal:
            key = self.w.list1.get()[dropInfo['rowIndex'&rsqb;&rsqb;
            for item in self.draggedItems:
                if item not in self.weekdays[key]:
                    self.weekdays[key] += [item]
            print(self.weekdays)
            return True
        return True

DragAndDropListItemsDemo()
</code></pre>
]]></description><link>https://forum.robofont.com/post/2427</link><guid isPermaLink="true">https://forum.robofont.com/post/2427</guid><dc:creator><![CDATA[RafaŁ Buchner]]></dc:creator><pubDate>Thu, 13 Jun 2019 11:18:48 GMT</pubDate></item><item><title><![CDATA[Reply to drag and drop between vanilla lists on Thu, 13 Jun 2019 11:20:28 GMT]]></title><description><![CDATA[<p dir="auto">I think that dragging callback always has to return True, maybe the first line <code>return True</code> is not necessary then</p>
]]></description><link>https://forum.robofont.com/post/2428</link><guid isPermaLink="true">https://forum.robofont.com/post/2428</guid><dc:creator><![CDATA[RafaŁ Buchner]]></dc:creator><pubDate>Thu, 13 Jun 2019 11:20:28 GMT</pubDate></item><item><title><![CDATA[Reply to drag and drop between vanilla lists on Thu, 13 Jun 2019 22:48:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/207">@RafaŁ-Buchner</a> that’s it!! thank you very much.</p>
]]></description><link>https://forum.robofont.com/post/2429</link><guid isPermaLink="true">https://forum.robofont.com/post/2429</guid><dc:creator><![CDATA[gferreira]]></dc:creator><pubDate>Thu, 13 Jun 2019 22:48:52 GMT</pubDate></item></channel></rss>