Hi Rob, Very nice for a learning exercise.
There are 2 problems, which are possible to solve.
a) actioins inside the button body
b) Adding a line-break character at the end of the new element in Data tiddler
add a)
The content inside of the button widget body is only updated, once when the button-widget is drawn.
So in your case it does not update the $value={{{
transclusion. So it needs to be added to the button actions-parameter.
add b)
In the $value=
assignment you read the existing content of the Data-tiddler and you add the new text. That’ right. – But you also need to add a line-feed control character. The problem with LF is, that it needs to be a binary-value. That’s why a charcode Operator exists
Here is the fixed code, that I did reformat a bit for easier readability.
\procedure enterActions()
<$action-setfield $tiddler="Data"
$value={{{ [{Data!!text}addsuffix[* ]addsuffix{!!temp-input}addsuffix<.lf>] }}}
/>
\end
\function .lf() [charcode[10]]
<style> input.testclass { border-top:none; border-left:none; border-right:none; color: grey; outline: none; border-bottom-width:thin;width:95%;}</style>
<$edit-text field="temp-input"
placeholder="Add new entry here"
default=""
tag="input"
class="testclass"
/>
<$button actions=<<enterActions>>
class="tc-btn-invisible tc-tiddlylink"
tooltip="Add entry"
>
{{$:/core/images/new-button}}
</$button>
{{Data}}
I did add a function \function .lf() [charcode[10]]
… which defines the binary representation of the line-feed character. Be aware of the leading .
dot in the .lf
function name. It is used to indicate that it is a function. It can be added using addsuffix<.lf>
in the \procedure enterActions()
– Which is also new.
The button-widget now uses actions=<<enterActions>>
, which IMO also makes it easier to read. Using it that way, the action is refreshed, whenever the button is clicked. So it will read the actual content of the Data-tiddler.
If you want to get rid of the temp-input
value if the + button is clicked, you can delete the temp-tiddler using the action-deletetiddler widget
BUT I leaf that example for you to solve. Hint: You can add it to the enterActions() procedure. It’s plural for a reason 
BUT but but – Make sure you have a backup of your code. action-deletetiddler can be destructive, if the tiddler title parameter is wrong.