prompt-for-string
message
&key
text
initial-value
print-function
value-function
ok-check
pane-args
popup-args
The function
prompt-for-string
prompts the user for a string and returns that string and a flag indicating that the dialog was not cancelled. The initial string can either be passed in as text using the
text
argument, or by passing
initial-value
and a
print-function
for that value.
print-function
defaults to
princ-to-string
. The value returned can be converted into a different value by passing a
value-function
, which by default is the identity function. This
value-function
gets passed the text that was entered into the pane, and should return both the value to return and a flag that should be non-
nil
if the value that was entered is not acceptable. If an
ok-check
is passed, then it should return non-
nil
if the value about to be returned is acceptable.
The prompter is created by passing an appropriate pane (in this case a 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-string "Enter a string:")
(capi:prompt-for-string
"Enter an integer:"
:initial-value 10
:value-function #'(lambda (x)
(let ((integer
(ignore-errors
(read-from-string x))))
(values integer
(not (integerp integer))
))))