Re: absent example in CAPI user manual
"Pascal Bourguignon (as informatimago at gmail dot com)" <[email protected]> Sat, 11 Apr 2026 13:23:37 +0200
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Igor, > On 11 Apr 2026, at 12:35, Igor Denisov (as defun-var at yandex dot ru) <[email protected]> wrote: > > Hello there, > > It would be nice to have such a CAPI code that does > > The code draws a window with one input field and one output field and one button. Then whatever you type in in input field will appear in output field when button is pressed. > > Could someone write it, please? > > Regards, > Igor > _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html Yes. Here is a small LispWorks 8.1 CAPI example with: one input pane one output pane one button When you click the button, the text from the input field is copied to the output field. (defpackage #:capi-demo (:use #:cl #:capi)) (in-package #:capi-demo) (capi:define-interface copy-text-example () () (:panes (input capi:text-input-pane :title "Input") (output capi:text-input-pane :title "Output" :enabled t) (copy-button capi:push-button :text "Copy" :callback #'copy-button-callback)) (:layouts (main-layout capi:column-layout '(input output copy-button))) (:default-initargs :title "CAPI Copy Example" :best-width 400 :best-height 150)) (defun copy-button-callback (button) (let* ((interface (capi:element-interface button)) (input-pane (slot-value interface 'input)) (output-pane (slot-value interface 'output)) (text (capi:text-input-pane-text input-pane))) (setf (capi:text-input-pane-text output-pane) text))) (defun run-copy-text-example () (capi:display (make-instance 'copy-text-example))) Call: (capi-demo:run-copy-text-example) A couple of notes: I used text-input-pane for both fields, because it is the simplest way to both read and display text. If you want the output field to be non-editable by the user, I can also give you a version using a display-pane instead. That is often cleaner for a true output field. </blink author=chatgpt> -- __Pascal Bourguignon__ [email protected]