[[HomePage]] > [[SoftwareIndex|Software Index]] > [[SoftwareDevelopment|Development]] > [[gtkdialog|gtkdialog]] > [[gtkdialogDocTips|Tips and Tricks]] ====9.12 Let <entry> accept (some) numbers only==== The following example shows how to limit the user input to a ##<entry>##. Useful for 'all' kinds of settings. %%(language-ref) export MAIN_DIALOG=' <vbox> <text> <label>"Enter a number (text will default to 0)"</label> </text> <entry editable="true" allow-empty="false"> <input>case $ENTRY in ""|*[^0-9]*) echo 0;; *) echo $ENTRY ;; esac</input> <variable>ENTRY</variable> <action signal="focus-out-event">refresh:ENTRY</action> </entry> <text> <label>"Enter a number within [5,15], otherwise: input will be capped at 15, floored at 5, or set to 10 in case of text input"</label> </text> <entry editable="true" allow-empty="false"> <input>A=$ENTRY2; case $A in [0-9]*) [[ $A -gt 15 ]] && echo 15 || [[ $A -lt 5 ]] && echo 5 || echo $A ;; *) echo 10;; esac</input> <variable>ENTRY2</variable> <action signal="focus-out-event">refresh:ENTRY2</action> </entry> <button ok></button> </vbox>' gtkdialog -p MAIN_DIALOG unset MAIN_DIALOG %% ===@@**#%[[gtkdialogDocTips9.11|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips9.13|Next ❱❱❱]]#%**@@=== ---- ==Categories== CategoryGtkdialog