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

Re: icon-dialog-item bug??



In article <CrLzyD.I77@dcs.gla.ac.uk>, kimb@dcs.gla.ac.uk (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! 
> 
There seems to be a bug in the following method
Karsten

(in-package :ccl)

(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
    (with-focused-view (view-container item)   ;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 (view-container item))
;;;;; Bug, was view-window, does not work if view-window and
;;;;; view-container don't have the same coordinate system
                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)))))))))