Change-callback in rich-text-pane on LWM4.4
Hi,
I'm trying to use the rich-text-pane in LWM4.4 but cannot seem to get
the change-callback to work. I've appended some code.
I'm assuming that this callback is supposed to be called whenever a
change is made to the editor. So try typing into the editor. No
callback is made.
I had a problem with the resize callback in the editor-pane. In that
case there was a default resize callback that I had to ensure was
called, then things worked. In this case, the documentation says the
default callback is nil. I verified this by not setting the callback
and checking if it was defined.
Can anybody see what I've done wrong?
Some notes:
1) I'm changing the parameter *rtf-ed-change* rather than using
something like format in case the IO streams are not right (see the
release notes for OS/X, no idea if this applies here, but just in case)
2) there are two ways of setting the callback: by init arg, by
accessor. There are functions defined in the test code for both.
Thanks,
Bob
; set this parameter in the callback in case the the IO streams are
wrong
(defparameter *rtf-ed-change* "no-change-reported")
(define-interface rtf-ed ()
()
(:panes
(editor rich-text-pane
:text "The RTF Editor"
:reader editor
:horizontal-scroll nil
:vertical-scroll t
;:change-callback #'(lambda (pane &key type) (format t
"CHANGE ~S to ~S~%" type pane))
:change-callback #'(lambda (&rest args)
(setf *rtf-ed-change* "changed"))
:visible-min-height '(:character 25)
:visible-min-width '(:character 80)))
(:layouts
(main-layout row-layout '(editor)
:reader main-layout))
(:default-initargs
:title "RTF Editor"
:layout 'main-layout
:best-width 600
:best-height 400))
; execute this if you want to use the callback defined in the init-arg
(defun run-using-init-arg ()
(let* ((interface (make-instance 'rtf-ed))
(ed (editor interface)))
(display interface)
(format t "The CHANGE-CALLBACK function: ~S~%"
(rich-text-pane-change-callback ed))))
; execute this if you want to explicitly set the callback
(defun run-setting-callback ()
(let* ((interface (make-instance 'rtf-ed))
(ed (editor interface)))
(display interface)
(setf (rich-text-pane-change-callback ed)
#'(lambda (&rest args) (setf *rtf-ed-change* "changed")))
(format t "The CHANGE-CALLBACK function: ~S~%"
(rich-text-pane-change-callback ed))))
----
Bob Hutchison -- blogs at <http://www.recursive.ca/hutch/>
Recursive Design Inc. -- <http://www.recursive.ca/>