Add testing-callback to textbox entry

This commit is contained in:
Jaidyn Ann 2024-02-04 21:47:56 -06:00
parent ce486ef5f6
commit 0259e06b99

View File

@ -14,6 +14,7 @@
;; along with this program. If not, see <https://www.gnu.org/licenses/>. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(import (chicken io) (import (chicken io)
(chicken string)
qt-light) qt-light)
@ -47,11 +48,36 @@
;; Connect callback functions to widgets signals. ;; Connect callback functions to widgets signals.
(define (window-callbacks window) (define (window-callbacks window)
(let ([fileexit (qt:find window "actionQuit")]) (let* ([fileexit (qt:find window "actionQuit")])
;; We connect to https://doc.qt.io/qt-6/qaction.html#triggered
(if fileexit (if fileexit
(qt:connect (qt:connect
fileexit "triggered()" fileexit "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) (init)