Just started using yad and read smokey01's tutorial which is great. I did not see an example of how to capture the OKCancel button clicks.
Thanks
wizard
Moderator: Forum moderators
Just started using yad and read smokey01's tutorial which is great. I did not see an example of how to capture the OKCancel button clicks.
Thanks
wizard
Big pile of OLD computers
Hi wizard, after the yad command;
[ $? -ne 0 ] && exit
(exit if not equal to 0)
So will exit when clicking Cancel ($? is return value, in case of Cancel it will return value 1, so exit the script)
The OK button will return value 0, so then the script will continue.
EDIT: But if you mean how to capture a variable output from yad, that's another thing and possibly required that you share your code.
Hi fredx181,
continuing on with what wizard said, there is another way to interact with buttons. You can run actions, such as call a function, when a button is clicked. However, wizard's methods of interaction are more commonly used.
As an FYI, I have made new YAD documentation in Notecase format. It is at https://github.com/w00fpack/YAD_Guides.
When I run this in a script and click OK I get no echo message in the terminal. Something wrong?
Code: Select all
yad [ $? -ne 0 ] && exit
echo OK was clicked
Thanks
Wizard
Big pile of OLD computers
wizard wrote: ↑Fri Dec 24, 2021 2:35 amCode: Select all
yad [ $? -ne 0 ] && exit echo OK was clicked
Usually OK returns 0 and Cancel returns 1. Not sure why it reverses with your example. maybe yad and the [ ] sections are being evaluated instead of just [ ].
For your example, the code can be shortened to
Code: Select all
yad && exit
echo OK was clicked
This alternate example might be helpful if your buttons have different return codes
Code: Select all
yad
if [ $? -ne 0 ]; then
exit
else
echo OK was clicked
fi
wizard wrote: ↑Fri Dec 24, 2021 2:35 amWhen I run this in a script and click OK I get no echo message in the terminal. Something wrong?
Code: Select all
yad [ $? -ne 0 ] && exit echo OK was clicked
You need a ; after yad:
Code: Select all
yad ; [ $? -ne 0 ] && exit
snoring_cat wrote: ↑Fri Dec 24, 2021 4:41 amFor your example, the code can be shortened to
Code: Select all
yad && exit echo OK was clicked
Should be rather
Code: Select all
yad || exit
echo OK was clicked
syntax, syntax, syntax, rules, rules, rules
drives me crazy, LOL
Merry Christmas
Thanks
wizard
Big pile of OLD computers