Edit-text widget

69 views
Skip to first unread message

Mohammad

unread,
Mar 13, 2019, 10:00:40 AM3/13/19
to TiddlyWiki
Consider the below macro.
It gets a filter and a JSON tiddler and adds all tiddlers from filter output to the JSON tiddler.


\define sl-macro(filter,tiddler)
<$button set=<<stateTid>> setTo="hide"> Select all
<$list filter=<<__filter__>> variable="Item">
<$action-setfield $tiddler=<<__tiddler__>> $index=<<Item>> $value="selected"/>
</$list>
</$button>
\end



No consider the below example
It has a textbox to get a filter from user and then call sl-macro

<$edit-text
tiddler="state/myExmp"
tag="input"
default=""
placeholder="filter search"
/>
<$macrocall $name=sl-macro filter="[subfilter{state/myExmp}]" tiddler="state/Myselection"/>

This works fine! My question is when I change the filter in a text box and try to add new set of selected tiddlers,
still the previous selection is there (in the JSON tiddler) I use the selected tiddler somewhere else for further processing!
Is there any way to detect the new filter in the textbox and remove the previous selection from JSON tiddler?!


--Mohammad

Mohammad

unread,
Mar 13, 2019, 10:07:15 AM3/13/19
to TiddlyWiki
Attached is a sample tiddler of above question to simple test on tiddlywiki.com!

For example try
"[tag[About]]" and then enter "[tag[Android]]".

I know pressing Add all has a button and you clear the previous list! But here my question is to remove previous selection on
filter change in editbox!

--Mohammad
Question.tid

Joshua Fontany

unread,
Mar 13, 2019, 2:08:03 PM3/13/19
to TiddlyWiki
Try this sl-macro. "Setting" an index without a value deletes that index.

```
\define sl-macro(filter,tiddler)
<$button set=<<stateTid>> setTo="hide"> Select all
<$list filter=<<__tiddler__>> variable="Remove">
<$action-setfield $tiddler=<<__tiddler__>> $index=<<Remove>> />
</$list>
<$list filter=<<__filter__>> variable="Item">
<$action-setfield $tiddler=<<__tiddler__>> $index=<<Item>> $value="selected"/>
</$list>
</$button>
\end
```

Joshua Fontany

unread,
Mar 13, 2019, 2:11:50 PM3/13/19
to TiddlyWiki
Actually, thinking about this you might want to follow the $:/AdvancedSearch pattern.

Store the output of the filter in a  $:/temp/* tiddler, and display those results in a list for the user.

Then have the button use the $:/temp/* tiddler as the source to clear/update the JSON tiddler.

Then the displayed list will auto-update as the user changes the filter, but it is up to them to confirm the new selection into permanent storage.

Best,
Joshua Fontany

Mohammad

unread,
Mar 13, 2019, 3:13:35 PM3/13/19
to TiddlyWiki
Thanks Joshua,
Yes, its possible to have a button to update the list.
I though if there is a way to detect the change in filter as textbox is updated!
This needs kind of action attribute which seems is not available in edit-text widget!

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