I’m further developing my mnemonic medium platform (that Grok TiddlyWiki is built on) and wanted to make an option where the person configuring the plugin could provide an arbitrary macro containing action widgets, to be triggered from somewhere within the plugin at an appropriate time. To edit settings like this, I have a custom control panel that provides text entry fields and documentation for a variety of settings:
The way this control panel works is there are a bunch of config tiddlers that have fields describing how they should show up in the control panel, and the text field of each is bound to the text entry field. Pretty standard. But the macro thing didn’t work the way I expected:
- First I tried tagging the tiddler being edited with
$:/tags/Macro. This caused the entire page to re-render and scroll up to the top every time the text was edited. This understandable, I guess, though I’m spoiled by the recent version that prevented loss of focus when editing fields of the current tiddler! - Then I tried removing the tag and
\importing the tiddler into a different tiddler containing thesendFeedbackLinkmacro (where the user-defined macro is called). This caused all of the macros in that tiddler to fail to be defined.
In this case I was able to use an $importvariables widget within the calling macro instead:
\define sendFeedbackLink(tooltip:"Suggest an improvement to this question.", icon:"" text:"send feedback")
<$importvariables filter="[[$:/config/sobjornstad/TakeAway/AuthorProvided/FeedbackActions]]">
<$button class="tc-btn-invisible tc-tiddlylink" tooltip=<<__tooltip__>>>
<<sendFeedbackAction>>
$icon$ $text$
</$button>
</$importvariables>
\end
Is it intended that \import doesn’t work properly within a tiddler containing macros after the directive? If so, we should probably add this to the documentation and suggest a workaround.
(Also, I’m not sure \import would have worked anyway – anything imported by \import presumably goes out of scope at the end of the tiddler, so it probably wouldn’t be accessible at the time the macro is called by somebody outside of that tiddler. I don’t think TiddlyWiki macros offer “closures” like this, do they? Maybe this should be mentioned too.)
