3 (defclass numeric-input
(input)
4 ((number-type :initarg
:number-type
:initform
'single-float
:accessor number-type
:type
(or symbol cons
)
5 :documentation
"A typespec of the type to coerce the number into on write."))
6 (:documentation
"Widget for editable numbers.
7 The writer initarg function will be automatically wrapped in
8 the initialize-instance so that it is given a number as the first argument."))
10 (defmethod initialize-instance :after
((numeric-input numeric-input
) &key writer
)
12 (setf (slot-value numeric-input
'writer
)
14 (let ((rval (read-from-string val
)))
16 (funcall writer
(coerce rval
(number-type numeric-input
)))))))))
18 (defmethod accept-char-p ((numeric-input numeric-input
) character
)
19 (or (eql #\. character
)
21 (digit-char-p character
)))