Code sample: one way of setting up a select widget as a drop-down menu

(You will find the code below in this TiddlyWiki’s “Home” tiddler.)

\define ⬥m(i v d) <option value="$v$" $d$>$i$ $v$</option>
\define 🔷dropDownMenu()
  <$select tiddler="$:/temp/SelectedTiddler" field="text" default={{Accueil / Welcome!!title}}>
    <$macrocall $name="⬥m" i=🏠 v={{Accueil / Welcome!!title}}/>
    <optgroup label='Phonologie / Phonology'>
      <$macrocall $name="⬥m" i=🔤 v={{Alphabet Phonétique / Phonetic Alphabet!!title}}/>
      <$macrocall $name="⬥m" i=🔊 v={{Aspects phonétiques / Phonetic Aspects!!title}}/>
    </optgroup>
    <optgroup label='Dictionnaire / Dictionary'>
      <$macrocall $name="⬥m" i=📕 v={{Dictionnaire orthographique / Spelling Dictionary!!title}}/>
      <$macrocall $name="⬥m" i=📗 v={{Dictionnaire phonétique / Phonetic Dictionary!!title}}/>
      <$macrocall $name="⬥m" i=📙 v={{Locutions / Phrases!!title}} d=disabled/>
    </optgroup>
    <$macrocall $name="⬥m" i=📚 v={{Références / References!!title}}/>
  </$select>
\end

About all of those {{...!! }}: It usually takes me many incremental/iterative tweaks, over long stretches of time, before I’m satisfied with a tiddler title. I depend heavily on the Relink plugin to alter every reference to a tiddler when I do change a tiddler’s title, and {{...!! }} is a no fuss no muss way of making sure Relink does its magic.

And: Using an emoji in a macro name just makes it easier to visually spot calls to that macro.

image

6 Likes

That’s very cool. Thanks for sharing.

Thank you!

That leads to a very attractive menu.

Three questions:

  1. What do you use the d parameter for? Adding class names?
  2. While I see that it’s easier to spot calls to the macro, how much harder do you find it to type them? I known, I know, “code is viewed much more often than it’s written”, but anything that slows down my groove is suspect. Do you find you can use these quickly?
  3. What was the third question I was going to ask? :slight_smile:

That, when specified, is for disabling the menu. Something for when I plan to add a menu item, or I’m working on one that isn’t ready for “prime time.”

<$macrocall $name="⬥m" i=📙 v={{Locutions / Phrases!!title}} d=disabled/>

I really don’t understand what you are asking. What do you mean by “type them”? What is “them” ?

Probably the same question that has cursed me since forever: “If a dried grape is a raisin, and a dried plum is a prune, why is a dried banana a dried banana? Were they playing some drinking game naming dried fruit, and got bored or ran out of ideas?”

1 Like

them = calls to the macro

Whenever I use characters in my code that are not quickly available on my keyboard, it slows me down. I assume that’s true for most people. I assume you find the tradeoff worthwhile. But do you have some technique to add emojis like that with little hassle?

Ditto, however …

When the related code is all in one place, and I will never type the code except for once, then it isn’t a concern. Every new menu item will be a copy/paste of the code for some already existing menu item, which I will then alter as needed for the new menu item. So the macro name with the emoji will never get typed (well, picked from a search dialog) again.

Honestly, almost everything I do is a copy/paste. For example: an edit widget. I never type that in from scratch. I copy and paste an existing edit widget, and then alter it as needed. So whether something has an emoji in the name or not, I likely will never type it all in from scratch.

Copy/paste because I could not be bothered memorizing anything, and I am very much averse to tendinitis of the keyboard-typie finger knuckles.