Hi Finn
Thanks Jeremy! I was able to get the button to show-up! I have a few more stupid questions, if you have the time, mainly related to styling these buttons and to wikitext.
Firstly, I would like the colour of the button to change onhover. While this is simple to do with CSS, I imagine it needs some sort of special stylesheet (styles.tid, perhaps), to do this. It would be great if you could share the syntax needed for this.
As you inferred, there are two parts: (a) assign a class to the button and (b) create a stylesheet with a :hover rule. Stylesheets are ordinary tiddlers with the tag “$:/tags/Stylesheet”, and (usually) the type “text/css”.
For dynamic effects, one can also use the wikitext type “text/vnd.tiddlywiki” and use wikitext primitives like <$list> to generate stylesheet rules dynamically.
Next and lastly, I am a bit confused as to how to implement this with JS. I would like to be able to get the tiddler text, and then call a JS function with this JS text as an argument. How could I go about getting the tiddler text when the button is clicked, and then have this transfer over to JS for the function call?
It sounds like you want to make a view toolbar button that calls a JS function to do something with the text of a tiddler. There are quite a few ways to do that, and the precise details will depend on what you’re trying to achieve. What does the JS function do with the text? Does it need to update the tiddler value in the store?
The key types of JS modules in TW5 are as follows:
- JS macros for simple deterministic text transformations that don’t have any side effects (eg they cannot modify the tiddler store)
- Widgets for dynamic components that reflect values in the tiddler store, and automatically refresh if the values in the store change
- Filter operators for operations on lists of items. Again, they mustn’t have side effects
- Savers for saving entire TiddlyWiki HTML files
- SyncAdaptors for saving/loading individual tiddlers to remote servers
There are some docs at TiddlyWiki/Dev — documentation for developers, and it’s worth browsing the code over at GitHub:
https://github.com/Jermolene/TiddlyWiki5/tree/master/core/modules
Sorry if these questions are a bit basic, but I have yet to find a good resource for learning WikiText/TW Syntax, so I have to rely on the community and you.
Not at all. It sounds like you’ve plenty of experience of HTML, CSS and JS which puts you in a great position. Some of it will be a matter of unlearning some of the usual ways of doing things. TiddlyWiki is a different beast: it tries to make it easy to write complex apps declaratively by composing a small number of higher level primitives. But it also tries to have it’s cake and eat it, in the way that it tries to expose the underlying flexibility of HTML, CSS and JS.
Best wishes
Jeremy