buffered refresh

master
Matthew Butterick 5 years ago
parent 6c307b6c6e
commit 4a767a1cda

@ -11,6 +11,11 @@
(define current-omit (make-parameter #f)) (define current-omit (make-parameter #f))
(define current-mandatory (make-parameter #f)) (define current-mandatory (make-parameter #f))
(define current-combo (make-parameter #f)) (define current-combo (make-parameter #f))
(define refresh-thread (thread void))
(define (buffered-refresh)
(set! refresh-thread (let ()
(kill-thread refresh-thread)
(thread (λ () (sleep 0.2) (refresh-wordbox))))))
(for ([param (list current-optional current-omit current-mandatory current-combo)] (for ([param (list current-optional current-omit current-mandatory current-combo)]
[str '("optional letters" "omitted letters" "mandatory letters" "mandatory combo")]) [str '("optional letters" "omitted letters" "mandatory letters" "mandatory combo")])
(new text-field% (new text-field%
@ -22,7 +27,9 @@
(param (match (send tf get-value) (param (match (send tf get-value)
[(? non-empty-string? str) str] [(? non-empty-string? str) str]
[_ #false])) [_ #false]))
(refresh-wordbox))])) ;; put delay on refresh so that rapid typing
;; doesn't trigger too many refreshes
(buffered-refresh))]))
(define current-min-size (make-parameter 3)) (define current-min-size (make-parameter 3))
(define current-max-size (make-parameter 20)) (define current-max-size (make-parameter 20))

Loading…
Cancel
Save