Thank you Mark, that was very helpful!

My main mistake was that I was trying to obtain the result of the list widget before using it, instead of using the variable inside the list loop. Indeed it makes sense that the emptyMessage parameter doesn't work, since it is not assigned to the list variable.

I was able to simplify your version a little: no need for the original macro as you mentioned, emptyMessage is not needed anymore, and I use the default list variable currentTiddler; I'm copying it below in case anyone else is interested.

Thanks again!
Erwan

-------------

\define filterNonDraftTitle()
  [all[current]get[draft.of]] [all[current]!regexp[^Draft of]]
\end

\define wrapper() [[$(currentTiddler)$]]

\define journalButton()
 <$button
     tooltip={{$:/language/Buttons/NewJournalHere/Hint}}
     aria-label={{$:/language/Buttons/NewJournalHere/Caption}}
     class=<<tv-config-toolbar-class>>
   >
   <$action-sendmessage
     $message="tm-new-tiddler"
     title=<<now "$(journalTitleTemplate)$">>
     tags=<<wrapper>>
   />
   <$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
     {{$:/core/images/new-journal-button}}
   </$list>
   <$list filter="[<tv-config-toolbar-text>prefix[yes]]">
     <span class="tc-btn-text">
       <$text text={{$:/language/Buttons/NewJournalHere/Caption}}/>
     </span>
   </$list>
</$button>

\end

<$list filter=<<filterNonDraftTitle>>>
   <<currentTiddler>>      <!-- debug -->
   <<journalButton>>
</$list>




On 29/11/14 21:45, 'Mark S.' via TiddlyWiki wrote:
I think anything evaluated within List needs to be "real" That is, the emptyMessage doesn't work the same as if you got real results. I'm sure someone will correct me on this if I'm wrong.

What I did was to

*(1) Change the filter so that something always gets iterated, *
*(2) enclose the button invocation inside list instead of set and use the variable feature to specify a "mytag" as the output, *
*(3) Create a macro to wrap mytag in brackets*
*(4) Use the wrapper with the tags attribute*

Maybe other stuff. It seems to work, assuming that your use case was that you wanted to invoke the button from preview mode and/or from the closed tiddler. I'm not sure if you even need the macros at this point other than the new wrapper macro. You can check that out if you want.

Mark
Code Below VVV




\define nonDraftTitle()
<$list filter="[all[current]get[draft.of]] [all[current]!regexp[^Draft]]" emptyMessage={{!!title}} variable="mytag" >
\end

\define evalNonDraftTitle()
   <$macrocall $name=nonDraftTitle/>
\end

\define wrapper() [[$(mytag)$]]

\define journalButton()
 <$button
tooltip={{$:/language/Buttons/NewJournalHere/Hint}}
aria-label={{$:/language/Buttons/NewJournalHere/Caption}}
class=<<tv-config-toolbar-class>>
   >
   <$action-sendmessage
     $message="tm-new-tiddler"
     title=<<now "$(journalTitleTemplate)$">>
     tags=<<wrapper>>
   />
   <$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/new-journal-button}}
   </$list>
   <$list filter="[<tv-config-toolbar-text>prefix[yes]]">
     <span class="tc-btn-text">
       <$text text={{$:/language/Buttons/NewJournalHere/Caption}}/>
     </span>
   </$list>
</$button>

\end

<$list filter="[all[current]get[draft.of]] [all[current]!regexp[^Draft]]" emptyMessage={{!!title}} variable="mytag" >
<<evalNonDraftTitle>>      <!-- debug -->
   <<journalButton>>
</$list>


On Saturday, November 29, 2014 6:58:01 AM UTC-8, Erwan wrote:


    Hi everyone,

    I'm trying to create a button based on the "new journal here" which
    would work even if the current tiddler is in edit mode. I can
    obtain the
    real title of the tiddler with:

    <$list filter="[all[current]get[draft.of]]"
    emptyMessage={{!!title}} />

    but I didn't find how to pass the result to the "tags" parameter
    in the
    action-sendmessage widget. I assume that I need to obtain the
    result as
    a string before transmitting it as a parameter, but I'm confused
    about
    when a macro or widget is actually evaluated. (I also tried using
    "macrocall" but probably not the right way)

    This is what I have currently:

    \define nonDraftTitle()
       <$list filter="[all[current]get[draft.of]]"
    emptyMessage={{!!title}} />
    \end

    \define evalNonDraftTitle()
       <$macrocall $name=nonDraftTitle/>
    \end

    \define journalButton()
       <$button
         tooltip={{$:/language/Buttons/NewJournalHere/Hint}}
         aria-label={{$:/language/Buttons/NewJournalHere/Caption}}
         class=<<tv-config-toolbar-class>>
       >
       <$action-sendmessage
         $message="tm-new-tiddler"
         title=<<now "$(journalTitleTemplate)$">>
         tags=<<nonDraftTitle>>
       />
       <$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
         {{$:/core/images/new-journal-button}}
       </$list>
       <$list filter="[<tv-config-toolbar-text>prefix[yes]]">
         <span class="tc-btn-text">
           <$text text={{$:/language/Buttons/NewJournalHere/Caption}}/>
         </span>
       </$list>
    </$button>
    \end

    <$set name="currentTiddlerTag" value=<<evalNonDraftTitle>>>
       <<evalNonDraftTitle>>      <!-- debug -->
       <<journalButton>>
    </$set>


    Thank you!
    Erwan

--
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 [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to