Prompts the user for an integer.
capi
prompt-for-integer message &key min max initial-value ok-check pane-args popup-args continuation => result, successp
message⇩ |
A string. |
min⇩ |
An integer or nil . |
max⇩ |
An integer or nil . |
initial-value⇩ |
An integer or nil . |
ok-check⇩ |
A function or nil . |
pane-args⇩ |
Arguments to pass to the pane. |
popup-args⇩ |
Arguments to pass to the confirmer. |
continuation⇩ |
A function or nil . |
result⇩ |
An integer or nil . |
successp |
A boolean. |
The function prompt-for-integer
pops up a text-input-pane and prompts the user for an integer, which is returned in result.
message supplies a title for the dialog.
When min or max are specified the allowable result is constrained accordingly.
initial-value determines the initial value displayed in the dialog. initial-value defaults to the value of min, or if min is nil
then no initial value is displayed.
Further restrictions can be applied by passing an ok-check function. ok-check should take one argument, the currently entered number, and should return t
if it is valid. If ok-check is nil
(the default) then there is no further restriction.
If continuation is non-nil, then it must be a function with a lambda list that accepts two arguments. continuation is called with the values that would normally be returned by prompt-for-integer
. On Cocoa, passing continuation causes the dialog to be made as a window-modal sheet and prompt-for-integer
returns immediately, leaving the dialog on the screen. The with-dialog-results macro provides a convenient way to create a continuation function.
The prompter is created by passing text-input-pane to popup-confirmer. Arguments can be passed to the make-instance of the pane and the call to popup-confirmer using pane-args and popup-args respectively.
(capi:prompt-for-integer "Enter an integer:")
(capi:prompt-for-integer "Enter an integer:" :max 10)
(capi:prompt-for-integer "Enter an integer:" :min 100 :max 200)
(capi:prompt-for-integer "Enter an integer:" :ok-check 'evenp)
prompt-for-string
popup-confirmer
text-input-pane
10 Dialogs: Prompting for Input
CAPI User Guide and Reference Manual (Macintosh version) - 01 Dec 2021 19:31:27