[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Windows vs. color-dialogs and getting a cpixel value


I am really stumped on something.  I have written a simple
color-dropper function which allows the user to get a color by
positioning an eye-dropper cursor on a point and clicking to get its
color value.  The problem I have is that this function returns the
correct color when defined as the dialog-item-action of a button when
that button is the subview of a window, but not when the button is the
subview of a color-dialog (it just seems to return black or white).
What is going on here?

Marc Davis
MIT Media Lab

******Code below (urgent help appreciated)*****

;function to get a color value at an x y
(defun getcpixelcolorvalue (x y)
    (with-rgb (rgb *black-color*)
              (#_getcpixel x y rgb)
              (rgb-to-color rgb)))

;Code to get a color value by clicking on a point 
;put your favorite cursor in here 
;(we took one from Studio 8, the *watch-cursor* from MCL works too.

(defvar *color-dropper-cursor* *watch-cursor*)

(defun get-color-with-color-dropper (&optional (color-dropper-cursor
    (with-cursor color-dropper-cursor
         (let ((color nil))
            (do () ((mouse-down-p))
                (let ((mouse-position (view-mouse-position nil)))
                   (setf color (getcpixelcolorvalue (point-h mouse-position)
						(point-v mouse-position)))))

;this works

(make-instance 'window
     :view-subviews (list (make-instance 'button-dialog-item
		#'(lambda (item)
			(declare (ignore item))
			(pprint (get-color-with-color-dropper))))))

;this does not

(make-instance 'color-dialog
     :view-subviews (list (make-instance 'button-dialog-item
                #'(lambda (item)
                        (declare (ignore item))
                        (pprint (get-color-with-color-dropper))))))