Ignore:
Timestamp:
12/13/2007 12:47:56 AM (18 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
tui
revision id:
dsowen@fugue88.ws-20071213004756-lr4quvaf0hy1zpub
Message:

Widgets now support validation (#1).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/widget/textbox.lisp

    r65 r80  
    1010(defclass textbox (widget scroll insertion-point)
    1111  ((data :initarg :data)
     12   (validator :initform 'identity :initarg :validator :reader validator)
    1213   (window :initarg :window)
    1314   (active :type boolean :initform nil)))
     
    6364
    6465
    65 (defun create-textbox (parent-window y x data width &key
     66(defun create-textbox (parent-window y x data width &rest args &key validator
    6667                       (inactive-background '(#\Space 0))
    6768                       (active-background '(#\Space 0)))
     69  (declare (ignore validator inactive-background active-background))
    6870  (let* ((window (tui-window::create-subwindow parent-window 1 width y x))
    69          (inst (make-instance 'textbox
    70                               :data data
    71                               :window window
    72                               :inactive-background inactive-background
    73                               :active-background active-background)))
     71         (inst (apply 'make-instance 'textbox :data data :window window args)))
    7472    (draw inst)
    7573    inst))
     
    123121                       (let ((r (funcall key-callback key)))
    124122                         (when r
    125                            (setf (insertion-point textbox) 0)
    126                            (return-from activate r)))
     123                           (let ((q (funcall (validator textbox) (text data))))
     124                             (when q
     125                               (setf (text data) q)
     126                               (setf (insertion-point textbox) 0)
     127                               (return-from activate r)))))
    127128                       (multiple-value-bind (left right) (split textbox)
    128129                         (setf (text data)
Note: See TracChangeset for help on using the changeset viewer.