Mike,

An action cannot directly contain wikitext that should appear -- it can 
generally only contain action widgets (there are a few exceptions, like you 
can use a list widget to create a bunch of actions matching some pattern). 
The general pattern for creating a button that hides/shows content is to 
create a field that contains information about whether or not to show the 
content, then use a $reveal or $list widget to control whether it appears. 
For instance, to use a field called "show-content" on the current tiddler 
to control the display:

\define show-actions() <$action-setfield show-content="yes"/>
\define hide-actions() <$action-setfield show-content="no"/>

<$reveal state="show-content" type="match" text="yes">
  <$list filter="[tag[About]]">
    <$link/>
    {{||$:/core/templates/static-tiddler}}
  </$list>
  <$button actions=<<hide-content>>>Hide me again</$button>
</$reveal>
<$reveal state="!!show-content" type="nomatch" text="yes">
  <$button actions=<<show-content>>>
    Click me!
  </$button>
</$reveal>

(Note that unlike in your example, I've included an action and button to 
hide the content again. You can of course take that out if you don't want 
it...but the only way to get the content to go away again will be to go in 
and manually change the field on the current tiddler.)

You might also like to use a temporary tiddler, rather than a field on the 
current tiddler, to store whether the content should be open. If so, you 
would do something like:

\define show-actions() <$action-setfield $tiddler=<<qualify 
"$:/temp/MyContentIsOpen">> show-content="yes"/>

<$reveal state=<<qualify "$:/temp/MyContentIsOpen">> type="match" 
text="yes">

<<qualify>> may not be necessary depending on your use case -- it prevents 
name collisions if you use this as a template on multiple tiddlers 
(otherwise, clicking the "show" button on one tiddler that uses the 
template will result in the content showing on all of them).

More information: Hiding and Showing Things 
<https://groktiddlywiki.com/read/#Hiding%20and%20Showing%20Things> (Grok 
TiddlyWiki), action widgets <https://tiddlywiki.com/#ActionWidgets> (TW 
docs), $reveal widget <https://tiddlywiki.com/#RevealWidget> (TW docs), qualify 
macro <https://groktiddlywiki.com/read/#Qualification> (Grok TiddlyWiki).
On Sunday, July 4, 2021 at 7:47:10 AM UTC-5 miket...@gmail.com wrote:

> For the button I want to make an Action. I took the example from the help 
> as a basis, but of course it does not work :)
>
>
>
>
>
>
>
>
>
>
> *\define my-actions()    <$list filter="[tag[About]]">    <$link/>   
>  {{||$:/core/templates/static-tiddler}}    </$list>\end<$button 
> actions=<<my-actions>>>Click me!</$button>*

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/5f8b9f90-8c60-4225-9873-a59dcfdd2ce5n%40googlegroups.com.

Reply via email to