@Mat: Thanks for your reply! Yes, I know that I can pass empty strings as 
arguments but I don't want to end up with empty keys. And I had no idea how 
to skip a key if an empty string was given.

@Eric: Awesome! This works perfectly. Thank you!


Am Sonntag, 19. April 2020 17:24:54 UTC+2 schrieb Eric Shulman:
>
> On Sunday, April 19, 2020 at 8:05:31 AM UTC-7, MaxGyver wrote:
>>
>> I often use the *kbd* tag for showing (keyboard) keys in my TiddlyWiki, 
>> like that:
>> \define combo3(key1: "Ctrl", key2: "Shift", key3: "x") <kbd>$key1$<
>> /kbd>+<kbd>$key2$</kbd>+<kbd>$key3$</kbd>
>> So I can write:
>> <<combo3 Ctrl Shift A>>
>> Is is possible to create a single macro that works for either one, two or 
>> three keys? 
>>
>
> This will do what you want:
> \define key(key1,key2,key3)
> \whitespace trim
> <kbd>$key1$</kbd>
> <$reveal text="$key2$" type="nomatch" default="">+<kbd>$key2$</kbd></
> $reveal>
> <$reveal text="$key3$" type="nomatch" default="">+<kbd>$key3$</kbd></
> $reveal>
> \end
>
> With the above macro, you can then write any of the following
> <<key Ctrl>>
> <<key Ctrl Shift>>
> <<key Ctrl Shift A>>
>
> Note: The <$reveal> widget usually takes a "state" parameter, which is the 
> name of a tiddler containing a text field with the value to compare.  By 
> omitting the "state" parameter, and using the "default" parameter instead, 
> you can use $reveal to compare two literal values, without needs a tiddler 
> in which to store a state value.
>
> enjoy,
> -e
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/08ec3250-4758-4240-be94-92b4ae7cb244%40googlegroups.com.

Reply via email to