5

for example i would like to configure the cancel button of this dialog box.

dialog --backtitle "Dialog - Form sample" \
 --form " Form Test - use [up] [down] to select input field " 21 70 18 \
 "Network-ID:" 2 2 "" 2 15 20 0\
 "Subnet Mask:" 4 2 "" 4 15 20 0\

how can i do this ?

Zermingore
  • 743
  • 2
  • 11
  • 28
Fimo
  • 51
  • 1
  • 2

1 Answers1

0

Also, note that the interpretation of $? as to "Whether Cancel was chosen" can be the other way around:

When 'Cancel' was chosen, only then is $? -eq 1 and on the other hand, when a proper menu choice was chosen, $? is 0 (and the choice itself is in another variable that you define yourself).

Example code:

exec 3>&1
result=$(dialog --title "Choose action from menu" \
       --menu "\n        Use arrows - UP/DOWN \n\                              
       Press [Enter] to select\n" 20 40 10 \
       "I"       "Installation" \
       "S"       "Check system" \
       "X"       "eXit" 2>&1 1>&3);

Now the dialog by default also shows a OK and Cancel buttons.

If user has chosen "OK", then $? = 0, and $result = 'I' or 'S' or 'X' If user has chosen "Cancel", $? = 1, and the $result was undefined ('')

My 'dialog --version' is 1.3-20160209

sheldonzy
  • 5,505
  • 9
  • 48
  • 86
Jukka Paulin
  • 11
  • 1
  • 4