Tiny Core Linux
Tiny Core Base => TCB Bugs => Topic started by: PDP-8 on August 08, 2019, 01:51:45 AM
-
TinyCorePure64 10.1 :
If you aren't using a mouse to click on yes / no, but instead are using the return key OR the space key to register a "NO", they return different values. Use TAB to navigate to "no" button.
Example:
popask using the return/enter key to register a "yes" = 1
popask using the SPACE key to register a "yes" =1
Fine.
Use the TAB key to navigate to NO button.
popask using return/enter to register "no" = 1
popask using SPACE key to register "no" = 0
So, not a showstopper, BUT in the hands of the unskilled who might just actually use the space/return keys instead of a mouse, may result in unintended actions.
-
Hi PDP-8
It seems it's not a bug:
Description
Displays a printf-style message in a pop-up box with an "Yes" and "No" button and waits for the user to hit a button. The return value is 1
if the user hits Yes, 0 if they pick No or another dialog box is still open. The enter key is a shortcut for Yes and ESC is a shortcut for No.
Note: Common dialog boxes are application modal. No more than one common dialog box can be open at any time. Requests for
additional dialog boxes are ignored.
Found here:
https://www.fltk.org/documentation.php/doc-1.1/functions.html#fl_ask
-
Hi guys,
How to catch the Yes No output?
I tried
(https://i.ibb.co/PmbPPsW/Screenshot-2021-09-24-122909.png)
I always get No - regardless I clicked yes or no
-
Hi pek
Check out xmessage. It's part of Xorg-7.7-bin.tcz. Example:
tc@E310:~$ xmessage -buttons Yes:1,No:2,Maybe:3 -print -center "Hello, World!"
Maybe
tc@E310:~$ echo $?
3
tc@E310:~$
This tells xmessage to create a popup with 3 buttons, Yes, No, and Maybe.
The numbers are the exit code you want for each button. The exit code can be found in $?
The -print option tells it to print the name of the button selected.
The -center option tells it to place the popup in the center of the screen.
Just entering xmessage produces a help screen.
-
Hi Rich..
Sorry I was asking about popask.
I don't have xorg, only xfbdev. So I don't have xmessage either.
Back to popask..
popask
clicked yes.. gives 1
and
popask
clicked no.. gives 0
How to catch that 1 or 0 so I can make and if loop?
Thanks.
-
Hi pek
When you click a button, popask exits and returns an exit code. That exit code (0 or 1) will be in the $? variable.
This will display the value of the exit code:
echo $?
Test it like this for No:
if [ "$?" == 0 ]
-
Hi pek
Ignore the previous post. It seems popask doesn't use the exit code for this. Try this:
VAR="`popask "Your text."`"
The value will be in $VAR. Those are not single quotes, they are back ticks.
-
Hi Rich..
Strangely no matter if I clicked yes or no, it always give me 0 for $?.
when I click yes
$ popask
$ 1
$ echo $?
$ 0
when I click no
$ popask
$ 0
$ echo $?
$ 0
So, it actually spitted out 1 or 0 after clicking.. But the $? always gives 0, regardless.
-
Hi pek
You missed the corrected answer I added.
-
Yes, I missed this one.
Hi pek
Ignore the previous post. It seems popask doesn't use the exit code for this. Try this:
VAR="`popask "Your text."`"
The value will be in $VAR. Those are not single quotes, they are back ticks.
This works as intended.
Thank you very much Rich.. It's brilliant :) :)
-
Hi pek
You are welcome. Glad I could help.