[TW5] Select field changing multiple variables

244 views
Skip to first unread message

The Bo

unread,
Nov 10, 2016, 3:02:46 AM11/10/16
to TiddlyWiki
Hello,

I'm looking for a way to build a select field (selectwidget) where I can change the layout of the wiki.

Until now I use this code:
<$select tiddler="$:/themes/tiddlywiki/vanilla/metrics/fontsize" default="Textsize" tag="input">

<option value='11px'>80%</option>
<option value='13px'>90%</option>
<option value='16px'>Textsize</option>
<option value='18px'>110%</option>
<option value='20px'>120%</option>


Now I want to change more variables (e.G. storywidth, bodylineheight etc.) but I want to use only one select field.

I haven't found a solution yet.

Regards,
The Bo

PMario

unread,
Nov 10, 2016, 3:20:21 AM11/10/16
to TiddlyWiki
Hi Bo,

You could create several theme, that sets all your values at once. So you can use the built in theme chooser.

There has been a plugin named tinka, to create plugins without the need of nodejs. see: http://tiddlywiki.com/#TWGuides%20by%20Andreas%20Hahn ... but it seems to be gone. has it been on github?? ..Does someone have a copy?

-m


PMario

unread,
Nov 10, 2016, 3:25:16 AM11/10/16
to tiddl...@googlegroups.com
On Thursday, November 10, 2016 at 9:20:21 AM UTC+1, PMario wrote:
 ..Does someone have a copy?

Mark S.

unread,
Nov 10, 2016, 12:36:02 PM11/10/16
to TiddlyWiki
Since there's no documentation for how to make a theme, using your own stylesheets may be easier. What you can do is make a selection drop-down like this:

<$select tiddler="SampleReveal1" default="set1" >
<option value="set1">Small Blue</option>
<option value="set2">Medium Red</option>
</$select>


Then you can make a stylesheet (regular tiddler tagged with $:/tags/Stylesheet) like this:

\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html

<$reveal type="match" state="SampleReveal1" text="set1">
.tc-tiddler-body h2 {
color
: blue ;
font
-size: 12px ;
}
</$reveal>
<$reveal type="match" state="SampleReveal1" text="set2">
.tc-tiddler-body h2 {
color: red ;
font-size: 24px ;
}
</
$reveal>

I've used my own font/sizes/colors as an example, but you get the idea.

Getting back to your original question, if you were really set on changing values inside the existing theme structure, you could do it in 2 steps. In the first step, you select the group of styles you want from your drop-down. A series of reveal widgets would then reveal a button. Inside the button, you could use the action-setfield widget(s) to set as many values as you wanted. You would then click on the button to invoke the changes. So, 2 clicks/options from the users stand-point. The reason it takes two steps is because you can't currently use the <$select> widget to activate the action-setfield widget ... or at least I don't think you can. Only the button widget can be used to send multiple messages at once.

Good luck!
Mark

Jeremy Ruston

unread,
Nov 10, 2016, 1:04:12 PM11/10/16
to tiddl...@googlegroups.com
Hi Mark

On 10 Nov 2016, at 17:36, 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:

The reason it takes two steps is because you can't currently use the <$select> widget to activate the action-setfield widget ... or at least I don't think you can. Only the button widget can be used to send multiple messages at once

Since 5.1.13 there’s been a new “actions” attribute that can be used on the select widget (and the keyboard widget). It is typically used by setting it to a macro defined in the same tiddler:

\define my-actions()
<$action-sendmessage $message=mymessage/>
<$action-setfield $tiddler=mytiddler $value=<<myvalue>>/>
\end

<$select tiddler="SampleReveal1" default="set1” actions=<<my-actions>>>

<option value="set1">Small Blue</option>
<option value="set2">Medium Red</option>
</$select>

Best wishes

Jeremy

Thomas Elmiger

unread,
Nov 10, 2016, 2:56:35 PM11/10/16
to TiddlyWiki
Hi Mario and Bo

I recently realized that I left the most recent version (0.2.0) of Tinka in my plugin wiki here: http://tid.li/tw5/plugins.html#%24%3A%2FControlPanel

Good luck!
Thomas

The Bo

unread,
Nov 11, 2016, 6:20:12 AM11/11/16
to TiddlyWiki
Thanks for all your answers!

I really like Mark's solution because it's quite simple to implement and is working very clean.

Regards,
The Bo
Reply all
Reply to author
Forward
0 new messages