droppable and draggable widgets

73 views
Skip to first unread message

Mohammad

unread,
Dec 19, 2019, 2:48:41 PM12/19/19
to TiddlyWiki
Summary:
 How to drag and drop a tiddler from one droppable area to another droppable area
 where the action tiddler removed from list field of tiddler 1 and added to list field of tiddler 2
  1. There are 4 tiddlers: tid1, tid2, tid3, and tid4
  2. Two of them are listed in the list field of tiddler a
  3. The other two of them are listed in the list field of tiddler b
  4. I have two droppable areas
    1. the droppable area for a lists tiddlers in tiddler list field
    2. the droppable area for b lists tiddlers in tiddler b list field
  5. I drag tid3 from b droppable area to a droppable area
  6. I wish an action to
    1. remove tid3 from list field of b
    2. add tid3 to list field of a
I appreciate your help and suggestion

--Mohammad

Eric Shulman

unread,
Dec 19, 2019, 3:34:22 PM12/19/19
to TiddlyWiki
On Thursday, December 19, 2019 at 11:48:41 AM UTC-8, Mohammad wrote:
Summary:
 How to drag and drop a tiddler from one droppable area to another droppable area
 where the action tiddler removed from list field of tiddler 1 and added to list field of tiddler 2

I just recently wrote something similar for the custom TOC macro I use in InsideTiddlyWiki.

Here's a link to my code:

and here's an excerpt showing the relevant handling:
\define toc-item-drop()
<!-- get OLDTAG and NEWTAG, exclude special tags -->
<$vars sourcetags={{{ [<actionTiddler>get[tags]] }}}
       targettags
={{{ [<item>get[tags]] }}}>
<$vars oldtag={{{ [enlist<sourcetags>!enlist<toc-ignore-tags>] }}}
       newtag
={{{ [enlist<targettags>!enlist<toc-ignore-tags>] }}}>
<$reveal default=<<modifier>> type="match" text="normal"> <!-- DROP AS SIBLING -->
   
<$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="-[<oldtag>]" />
   
<$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="[<newtag>]" />
   
<$action-listops $tiddler=<<oldtag>>        $field="list" $subfilter="-[<actionTiddler>]" />
   
<$action-listops $tiddler=<<newtag>>        $field="list" $subfilter="+[insertbefore:item<actionTiddler>]" />
</$reveal>
<$reveal default=<<modifier>> type="match" text="shift"> <!-- DROP AS CHILD -->
   <$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="-[<oldtag>]" /
>
   
<$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="[<item>]" />
   
<$action-listops $tiddler=<<oldtag>>        $field="list" $subfilter="-[<actionTiddler>]" />
   
<$action-listops $tiddler=<<item>>          $field="list" $subfilter="[<actionTiddler>]" />
</$reveal>
</
$vars>
</$vars>
\end

Note that I am manipulating both "tags" and "list" fields (the TOC uses entries in the "tags" field to define a tiddler (the "actionTiddler") as a "child" of a specific "branch" (the "item") of the tree, and the branch itself uses the "list" field to set the order of display for it's "children").  Also notice that I have different handling for "shift-drop" vs. regular "drop".  

While this isn't exactly what you are trying to do, perhaps it will give you some clues that help you find the right direction...

enjoy,
-e

Mohammad

unread,
Dec 19, 2019, 3:54:03 PM12/19/19
to TiddlyWiki
Many thanks Eric!
I will go through it and try to use in my case and then come back with my results!

Actually I am working on the favorites plugin and I am trying  to create favorites folder
but I don not want to use a lot of tags! So, I am working with list field and a folder tiddler!

Cheers
Mohammad

Mohammad

unread,
Dec 19, 2019, 4:33:43 PM12/19/19
to TiddlyWiki
Hi Eric,
 It works, a million thanks!

I had to modify my drop actions based on your code!

\define drop-actions()
<$vars oldFolder={{{ [<actionTiddler>listed[]] +[subfilter<folders>] +[limit[1]]}}}>
<$action-listops $tiddler=<<oldFolder>>       $field="list" $subfilter="-[<actionTiddler>]"        />
<$action-listops $tiddler=<<__folder__>> $subfilter='+[insertbefore:currentTiddler<actionTiddler>]'/>
</$vars>
\end


  • First I found where it has been listed (it always listed in one favorites folder
  • Then I remove it from the list of old folder
  • In the next step I add it to the list field of new folder
Cheers
Mohammad

TonyM

unread,
Dec 19, 2019, 5:20:18 PM12/19/19
to TiddlyWiki
FYI

The Kanban implementations in tiddlywiki do this kind of operation if you are looking for more inspiration.

Regards
Tony

Mohammad

unread,
Dec 19, 2019, 11:52:47 PM12/19/19
to TiddlyWiki
Thanks Tony!
I will have a look!

--Mohammad
Reply all
Reply to author
Forward
0 new messages