Thread View: comp.lang.lisp.mcl
2 messages
2 total messages
Started by Bill St. Clair
Mon, 25 Jan 1993 16:48
Re: Windows vs. color-dialogs and getting a cpixel value
Author: Bill St. Clair
Date: Mon, 25 Jan 1993 16:48
Date: Mon, 25 Jan 1993 16:48
85 lines
3741 bytes
3741 bytes
At 13:15 1/23/93 -0500, mdavis@media.mit.edu wrote:
>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
>
The problem was that your get-color-with-color-dropper function was
using the global mouse position and the currently focused view.
Since it was called from inside of:
(method view-click-event-handler (button-dialog-item)
it ended up being focused on the right window, but it appeared to
work for the window and not the color-dialog, because the window
was near the upper-left hand corner of the screen where window
coordinates are similar to global (screen) coordinates. The following
works for both:
To: info-mcl@media.mit.edu
Cc: mdavis@media.mit.edu
Subject: Windows vs. color-dialogs and getting a cpixel value
Date: Sat, 23 Jan 93 13:15:58 -0500
From: mdavis@media.mit.edu
X-Mts: smtp
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
;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 (window &optional (color-dropper-cursor *color-dropper-cursor*))
(with-focused-view window
(with-cursor color-dropper-cursor
(do ()
((mouse-down-p)
(let ((mouse-position (view-mouse-position window)))
(getcpixelcolorvalue (point-h mouse-position)
(point-v mouse-position))))))))
(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
(view-window item)))))))
(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
(view-window item)))))))
Re: Windows vs. color-dialogs and getting a cpixel value
Author: mdavis
Date: Mon, 25 Jan 1993 16:18
Date: Mon, 25 Jan 1993 16:18
8 lines
814 bytes
814 bytes
Thank you so much. The fix worked. By focusing the view on the view-window the color-dropper returns the correct color value! Thanks for offering excellent support. Marc Davis MIT Media Lab
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads