I use the abovegiven select widget in my topbar to list the tiddlers in the storyriver.
Now I was thinking whether I can add a close button to the side of each listed tiddlers in the select widget. That close button should be able to remove that tiddler from the list field of $:/StoryList. Is this possible.
As far as I understand, the selectwidget is a bit funny in that it combines a tiddlywidget with the option html elements. The latter is unlikely to permit much flexibility in what can be inside it.
Instead, you probably need to create your own selectwidget. I would start by using an edittextwidget and a revealwidget and inside the revealwidget use the listwidget showing each title along with a buttonwidget that probably uses a listops to remove titles from the storylist.
That is still a selectwidget with option elements inside so I’d say that it is still a problem to insert a button for the options.
I would do something like this. Sorry for not giving a complete answer but I’m busy with other stuff. You also seem to want to style the list so I threw in a div:
Have you tried the multiple option on the select widget, you can check/uncheck selected tiddlers but it is not a dropdown/popup, But perhaps you could wrap the whole selection with a click to open or place it in a MODAL?
Adding functional content to the <option> elements of a $select widget is tricky, because HTML doesn’t allow other elements (such as a “close” button) to be rendered within the <option> elements.
However, it IS possible to FAKE that functional content…
First, we define some convenient “abbreviations” that make the code easier to read:
close() will be used to perform the “close current tiddler” action
click() is used with $eventcatcher to handle clicks on the $select widget’s option elements. Note how the <<close>> action is only performed if the click occurs within the rightmost 20 pixels of the option element. You may need to adjust this value to match the font size of your rendered $select list.
The <style> CSS adds an at the right edge of each option element. Note the use of .myStoryList to limit this CSS rule so it is applied only to the $select list that has that class and won’t affect any other $select lists.
Next, add an $eventcatcher to catch the clicks on the $select widget’s list options and invoke the <<click>> handler. This will occur after the normal $select widget handling that assigns the selected option value to $HistoryList!!current-tiddler.
In order for this all to work, the $select widget has to have a size greater than 1 (i.e., a listbox, not a standard browser-based droplist). To make the listbox appear AS IF it was a droplist, we use a $button/$reveal popup combination. So, we start by defining a suitably qualified popid value to use with the $button and $reveal widgets.
Then, render the $button to trigger the popup, followed by the $reveal containing the popup contents.
The $reveal uses style="width:max-content;" to ensure that the popup leaves room for the “fake close button”.
Finally, render the $select widget inside the popup:
Set the size of the $select widget to a maximum of 10 items, and a minimum of 2 items. If there are more than 10 items, the $select widget will automatically get a scrollbar.
Add the myStoryList class so the CSS rule we previously defined can be applied to the option elements to add the red X “fake button”.
Add focus="yes" to allow immediate keyboard navigation as soon as the $select widget is rendered.
Thank you @EricShulman and @pmario for sharing your solutions for the query in the OP. I am in the midst of a small journey. So I didn’t get time to test any of your suggestions. I will be back home only after one week. I will give my feedback after reaching back home (since I don’t have a laptop in my possession to test those) Thank you once again for your help
@EricShulman and @pmario Thanks to both of you. Both solutions are good and pmario 's suggestion to use sidebar open code gives the drag and drop functionality also.
But now the idea which I have in my mind is to little complex. I need a pop up which shows both the currently open tiddlers in the storyriver and also the recently closed tiddlers in storyriver. I will open another thread for it. Thanks for your help.
It defines a tiddler toolbar button that uses a combination of the $:/HistoryList, $:/StoryList, and $:/DefaultTiddlers to display a popup containing a list of “viewed” tiddlers.
It also includes a “delete” button that resets the $:/HistoryList and $:/StoryList to contain only the current tiddler, and a “details” button that shows the current contents of the $:/StoryList!!list, the $:/DefaultTiddlers filter and the accumulated $:/HistoryList text and current-tiddler field values.
Is there any way to append and remove item to the list field of a tiddler one by one ?
That is when I close a tiddler from the storyriver using a custom button in the dropdown, it should be added to the list field of a tiddler called $:/state/recently-closed and simultaneosly removed from the list field of $:/StoryList.
Also when I reopen a tiddler in the recently closed list from the dropdown using a custom button, it should be added to the list field of $:/StoryList and simultaneosly removed from the list field of $:/state/recently-closed. That’s what i tried using the above given code. But it had some issues.
This code is working when I removed the + sign from <$action-listops $tiddler="$:/state/recently-closed" $field="list" $subfilter="+[<storylist-item>]"/>