[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: icon-dialog-item bug??
- To: kimb@dcs.gla.ac.uk (Kim Binsted), info-mcl@ministry.cambridge.apple.com
- Subject: Re: icon-dialog-item bug??
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Sat, 18 Jun 1994 16:55:30 -0400
At 8:08 PM 6/18/94 +0000, Kim Binsted wrote:
>Hi. I want to put up a dialog, put a view inside it, and put a
>clickable icon inside the view. This works - but only as long as the
>view is the top part of the dialog!
>
>I loaded "examples:icon-dialog-item.lisp" and then typed in the listener:
>
>(setf win (make-instance 'dialog))
>(setf vi (make-instance 'view))
>(setf ike (make-dialog-item 'icon-dialog-item
> nil nil ""
> #'(lambda (item) item
> (format *top-listener* "This works."))))
>(add-subviews vi ike)
>(add-subviews win vi)
>
>This works fine - click on the icon, and "This works" appears in the
>listener. But if you:
>
>(set-view-position vi #@(50 50))
>
>Then clicking on the icon no longer does anything (that I can see,
>anyway). Move vi back to the top of win, and the icon works again.
>
>What am I missing??
This is a new bug. Here's a (source) patch. Changes are CAPITALIZED.
(defmethod view-click-event-handler ((item icon-dialog-item) where)
(declare (ignore where))
(let* ((pos (view-position item))
(inverted-p nil) ;true when the mouse is over the icon
(CONTAINER (VIEW-CONTAINER ITEM)))
(with-focused-view CONTAINER ;Draw in the container's coordinates
(rlet ((temp-rect :rect ;temporarily allocate a rectangle
:topLeft pos
:botRight (add-points pos (view-size item))))
(without-interrupts
(#_invertrect temp-rect) ;initially invert the icon.
(setq inverted-p t)
(loop ;loop until the button is released
(unless (mouse-down-p)
(when inverted-p ;if button released with mouse
; over the icon, run the action
(dialog-item-action item)
(#_invertrect temp-rect)
(setq inverted-p nil))
(return-from view-click-event-handler))
(if (#_PtInRect
(view-mouse-position CONTAINER)
temp-rect) ;is mouse over the icon's rect?
(unless inverted-p ;yes, make sure it's inverted.
(#_invertrect temp-rect)
(setq inverted-p t))
(when inverted-p ;no, make sure it's not inverted.
(#_invertrect temp-rect)
(setq inverted-p nil)))))))))