Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

drei doesn't propagate value changed for text-filed on backspace #726

Closed
dkochmanski opened this issue Mar 4, 2019 · 2 comments
Closed

Comments

@dkochmanski
Copy link
Member

Steps to reproduce:

  1. run code below
  2. type some characters in a bottom pane

Expected: application pane shows "unshadowed password" and text-field shows stars of the same length.

Observed: text-field-pane doesn't invoke value-changed-callback when backspace is pressed (but text-field-pane is updated).

(in-package #:clim-user)

(define-application-frame password ()
  ((pass :initform (make-array 0 :element-type 'character :adjustable t :fill-pointer t)
         :accessor pass))
  (:panes (app :application :display-function #'display)
          (txt (make-pane 'text-field-pane
                          :value ""
                          :width 100
                          :value-changed-callback
                          (lambda (gadget value &aux (frame *application-frame*))
                            (cond ((> (length value)
                                      (length (pass frame)))
                                   (vector-push-extend (alexandria:last-elt value) (pass frame)))
                                  ((< (length value)
                                      (length (pass frame)))
                                   (setf (fill-pointer (pass frame)) (length value))))
                            (unless (every (lambda (c) (char= #\* c)) value)
                              (setf (gadget-value gadget)
                                    (make-string (length value) :initial-element #\*))
                              (redisplay-frame-panes frame))))))
  (:layouts (default (vertically ()
                       app
                       txt))))

(defmethod display ((frame password) pane)
  (format pane "password is ~s!~%" (pass frame))
  (terpri pane))

(run-frame-top-level (make-application-frame 'password))
@nsrahmad
Copy link
Collaborator

nsrahmad commented Mar 6, 2019

@dkochmanski The bug is in above example itself. Note the redisplay-frame-panes call is inside unless, moving it out as a last call in lambda makes it work as expected.

@dkochmanski
Copy link
Member Author

silly me, you are right! thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants