ewan.chalmers
ewan.chalmers

Reputation: 16235

How to capture user selections with dialog

I am updating a shell script which uses dialog create a text-based UI.

When I create a radiolist or checklist, I can't figure out how to make a selection in the displayed dialog.

For example, taking an example from here:

#!/bin/sh
dialog --backtitle "OS info" --radiolist "Select OS:" 10 40 3 \
        1 "Linux" off \
        2 "Solaris" on \
        3 "HPUX" off \
2> result.txt
echo "User selection: " `cat result.txt`

In the resulting dialog, I can use cursor keys (or number keys 1-3) to change the highlighted item in the list. But I can't figure out how to actually select the item (set the X in its control).

When I highlight an item and press ENTER, the output is always "2".

UPDATE

I find I can make a selection by clicking an item with the mouse. I was expecting it to work with keyboard-only input.

I'd still be interested to know if there is a way to make a selection using the keyboard - I guess there must be.

Upvotes: 0

Views: 2917

Answers (2)

GC 13
GC 13

Reputation: 256

Yes, the 2 solaris option is kept selected. UNIX dialog raidolist uses spacebar key event to change the selection. Unless spacebar is used, we can change the selection, else default selection will be resulted.

Upvotes: 0

micke
micke

Reputation: 1048

Use space to select the highlighted item.

Upvotes: 3

Related Questions