home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!apple!cambridge.apple.com!mdavis@media.mit.edu
- From: mdavis@media.mit.edu
- Newsgroups: comp.lang.lisp.mcl
- Subject: Windows vs. color-dialogs and getting a cpixel value
- Message-ID: <9301231815.AA01030@media.mit.edu>
- Date: 23 Jan 93 18:15:58 GMT
- Sender: owner-info-mcl@cambridge.apple.com
- Lines: 56
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
-
-
- Hi,
-
- 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
- *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)))))
- color)))
-
- ;this works
-
- (make-instance 'window
- :view-subviews (list (make-instance 'button-dialog-item
- :dialog-item-action
- #'(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
- :dialog-item-action
- #'(lambda (item)
- (declare (ignore item))
- (pprint (get-color-with-color-dropper))))))
-