invoke a macro from a button

57 views
Skip to first unread message

vpl

unread,
Aug 4, 2017, 11:07:22 AM8/4/17
to TiddlyWiki
Hi,

I cannot find a way to invoke a macro from a button

In the reference tiddly I've found what I need
For example the macro exemple "now Macro (Examples)"
A "try it" button invoke the now macro.

But this is done through another generic macro called ".example"
<$macrocall $name=".example" n="1" eg="""<<now>>"""/>

I can't find nowhere this code as an example that I could get some inspiration from ..

Can someone help me ?

Regards

Vpl

Mark S.

unread,
Aug 4, 2017, 11:54:22 AM8/4/17
to TiddlyWiki
The .example macro is defined in $:/editions/tw5.com/doc-macros. But it just wraps a reveal widget around the macro, so it may not be what you want.

What do you want to accomplish? Macros look like functions in programming languages, but often they work very differently.

Good luck,
Mark

vpl

unread,
Aug 4, 2017, 12:43:47 PM8/4/17
to TiddlyWiki
Thanks very much !
This solved my problem.
I've used the same mechanism as the doc-macro.

I've coded a javascript macro called "mymacro"
I use now the below code to invoke it when I click on the invoke. 

<$button set="$:/state/SampleReveal2" setTo="invoke">Invoke macro</$button>
<$reveal type="match" state="$:/state/SampleReveal2" text="invoke">
<<mymacro 3 40 52>>
</$reveal>

Is it the best way to do that ?

Regards
Reply all
Reply to author
Forward
0 new messages