There are editor toolbar buttons that do this already, making use of the WidgetMessage: tm-edit-text-operation some discussions have also occurred in “Discourse” in relation to handling selection outside the editor.
In the editorToolbar
- Have a look at customising the stamp tools
- See How to create dynamic editor toolbar buttons which makes use of WidgetMessage: tm-edit-text-operation
Now to get it into the list widget use your selection to either set a variable, field or tiddler to the selected value. One example may be a macro <$macrocall $name=mylist selection=<<selection>>/> in which you use “$selection$” “$(selection)$” or <<__selection__>> in your list widget/filter.
Outside the editor toolbar see this thread Can we access the ‘selection’ in the WidgetMessage: tm-edit-text-operation