Adding blank rows to a Prompt With List dialog

I've often wanted blank lines in some of my Prompt With List dialogs, to help with reading clarity–and as I tend to use these by typing to select, the length of the list doesn't bother me. Today, after some experimenting with various invisible characters, I found one that works:

The secret character that creates those lines? It's called the Hangul Filler. There are probably other Unicode characters that work, but this was the first one I found. Just click the "copy" link on that page, and it'll be on your clipboard. Paste as needed in your lists.

IMPORTANT EDIT: Depending on how you build your list, you may have to pad newlines around the invisible character. In my case, I'm buidling it with regex, so I'm using "[invisible character]\n" to add a line break before I put the next row in the list.

If you're going to do this, you'll also want to put your prompts in a repeat loop that repeats until the selection variable doesn't contain that character (and also exists), i.e. here's mine for the above dialog:

The first condition makes sure the user hasn't selected a header row, the second makes sure they didn't select the blank row (with the invisible character in the "contains box.).

The third entry covers any possibly empty value I might have managed to include while building the list, and the last makes sure the loop runs at least once, as the variable won't exist until after the prompt has been displayed.

-rob.

5 Likes

Hi, @griffman, thanks for sharing this clever tip; certainly one to add to the Keyboard Maestro tool belt. :grinning:

Curious, is there a reason you opt to use a While action versus an Until action? With some of my older macros I did the same as you, but now I'm opting to use the latter because it seems more intuitive (to me) and, unless I'm overlooking something, can include fewer conditions.


While on the topic of the Prompt With List action, I thought I'd contribute a few other techniques.

Including a Title Line

For some of my lists, I include a title (instructional) line. Like with your blank lines and group headers, I don't want the macro to proceed beyond the PWL if the user attempts to select that line. Thus I put the PWL in an Until action and define the line like this example: __👉🏿 Select a 𝗰𝗼𝗹𝗼𝗿 –or– ⇧:To View color reference page.

Invisible Grouping of Items

There are times, subsequent to the user selection, that I want to determine if the choice is within a group. If the group contains many items, the conditional logic can become unwieldily. One technique I've used to append an "invisible" character (U+200D : Zero Width Joiner) to the items in the group.

This character is not visible in the PWL, but can be easily detected in the macro logic.

Keyboard Maestro Export

Alternative Action

In some of my PWL's I want to provide an alternative option that can be selected using a combination of one or more modifiers and pressing <return>. This modifier+<return> should operate regardless of the currently selected line within the PWL.

For example, with the following PWL:

If the user presses ⇧+<return> the macro opens the reference page even if the title line is selected because of this Until action:

Keyboard Maestro Export


@griffman, thanks again for sharing your tip. In the macro below, I've combined it with my techniques.

Download: Prompt With List Techniques.kmmacros (15 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.5.2 (22G91)
  • Keyboard Maestro v10.2

1 Like

It's sort-of a toss-up to me—while these things aren't true, do this other thing, or do this thing until these other things are true. It's one less condition to use the Until action, as I don't have to check for an empty value. But really, I tend to write it either way :).

Unless I'm misunderstanding, you can do this in another way, using PWL's ability to store a different value than what's displayed, as explained on the PWL wiki page. Basically, you can name a return value, add two underscores, then put your visible text, like this:

House__I would prefer to rent a home
Apartment__I would prefer to rent an apartment

This way, the return from PWL isn't the long ugly text, it's whatever you put to the left of it. This lets you do some really cool stuff. Your codes, for instance, could just be part of those terms:

group1-varname__whatever text
group2-varother__etc
group1-varname__etc

Where this gets really powerful, though, is in the ability to use a variable on the left side of the expression, as I explained here:

Using Prompt With List to modify variables on the fly

My first PWL makes a new global variable, and the next uses that variable as input in the left side of the PWL box answers, thereby modifying the variable based on the user's selection. This is such a powerful feature, I've found myself using it often.

Now … if that's not what you're describing, I apologize for the off-topic meandering :).

-rob.

2 Likes

@griffman, good point. I've also used the friendly method you recommend. At the moment, I can't recall the circumstances that motivated me to use the Zero Width Jointer instead. Who knows, maybe it was before I was aware of the friendly feature. :person_shrugging:

Yes, I remember that thread. :+1:

I've created dynamic lists in several macros. One pitfall is when a value includes two or more consecutive underscores (e.g, with a file path and/or file name). In such cases the Prompt With List with Modifiers Optionally Pressed misinterprets the underscores in the values and the presentation gets garbled. In such cases, I do the following:

Keyboard Maestro Export

Now that's a creative solution!

-rob.