diff --git a/contact.scm b/contact.scm index 2e77c7c..9fe193b 100644 --- a/contact.scm +++ b/contact.scm @@ -14,6 +14,7 @@ ;; along with this program. If not, see . (import (chicken io) + (chicken string) qt-light) @@ -47,11 +48,36 @@ ;; Connect callback functions to widgets’ signals. (define (window-callbacks window) - (let ([file→exit (qt:find window "actionQuit")]) + (let* ([file→exit (qt:find window "actionQuit")]) + ;; We connect to https://doc.qt.io/qt-6/qaction.html#triggered (if file→exit (qt:connect file→exit "triggered()" - (qt:receiver exit))))) + (qt:receiver exit)))) + (textbox-callbacks window)) + + +;; Connect a text-printing callback to each textbox. +(define (textbox-callbacks window) + (let* ([property-names + '("address" "city" "company" "county" "eMail" "fax" + "homePhone" "name" "nickname" "state" "url" + "workPhone" "zip")] + [textboxes + ;; The texbox widgets are all named like “countryLineEdit”. + (map (lambda (property) + (qt:find window (conc property "LineEdit"))) + property-names)]) + ;; Cycle through each textbox, connecting them to a callback that prints + ;; their contents each time you type in text. + (map (lambda (textbox) + (if textbox + ;; We connect to https://doc.qt.io/qt-6/qlineedit.html#textChanged + ;; … and print the value of https://doc.qt.io/qt-6/qlineedit.html#text-prop + (qt:connect textbox "textChanged(QString)" + (qt:receiver + (lambda () (print (qt:property textbox "text"))))))) + textboxes))) (init)