From 0259e06b99a2be7ff5270d961aa75096082d7497 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Sun, 4 Feb 2024 21:47:56 -0600 Subject: [PATCH] Add testing-callback to textbox entry --- contact.scm | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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)