Bash & Xdialog - how to code to recognize ENTER key on keyboard.?
Hi all..
Bash scripting query again.. 1) Say I have the following snippet in a Bash script: Code:
Xdialog --screen-center --title "CONFIRM..!" --yesno "Are you sure you want to overwrite existing file?" 6 60 or do I need to use something like 'grep' or 'sed' to do this..? If so how..? 2) There is also another snippet of bash script that I would like to add this "ENTER" key code to as well: Code:
Xdialog --screen-center --title "$Key Input" --inputbox "The input should be an alphanumeric string or do I need to use 'grep' or 'sed' for this..? If so how..? The reason for this is - I have coded for an "OK" button in the Xdialog boxes - but I would like to allow for the user to use the "ENTER" key on the keyboard to do the exact same thing as clicking on the "OK" button as well..!! TIA. crafty. . . |
In your case you don't need to AFAIK.
0) Dialog apps rely on the user selecting the right button and then pressing enter to signify their choice and 1) since you're using a graphical interface your script isn't exposed to receive enters and 2) at least with Zenity the selection can only be one of two buttons, it can't be anything else so you wouldn't be able to send an enter unless you run something that intercepts the keyboard (and you don't want to do that) and 3) your users will be baffled by the inconsistency with other apps that don't exhibit that behaviour. You only need to work with the exit value, makes things easier for you and your users. |
In other words, pressing "Enter" is already being recognized -- it's the same as clicking on the currently selected button.
Why would you want to change a default behavior that is consistent w/ the vast majority of GUI apps., across desktop environments & even OS's? By chance, did you inherit the maintenance of this code? |
Thanks for the replies..
As shown - for the 'case' statements - 0) = covers the OK button; 1) = covers the CANCEL button; 255) = covers the 'close' button for the box window.. And in a fashion - the same for the 'if/then' grouping.. Just thought that there may have been ways to add in the extra for possible ENTER key usage as well.. @archtoad6 - Quote:
Yes and no - I actually wrote the script - so I'll have to maintain it as well.. Anyway - the script works well and does do what it was designed for - just thought that there might have been room for some slight improvement - especially towards those who prefer to use the keyboard more than a mouse.. Much appreciated for the replies though.. crafty. . . |
Quote:
|
craftybytes,
What was your distro/DE environment? (I was/am using MEPIS 6.0, KDE 3.5.3) |
.
Distro & DE environment = Puppy Linux v2.15CE (kernel 2.6.18.1); & iceWM & ROX..!! But my scripts are mainly in Bash & using Xdialog + a couple of 'yaf-splash' boxes.. So should work in ANY linux distro if got Bash & Xdialog.. Anyway - as I said previously - my scripts are working well and doing what I expected.. I'm of the belief though that - a little "positive" tweaking here & there does not go astray.. Thanks for the interest.. crafty. . |
All times are GMT -5. The time now is 11:11 AM. |