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

point-in-item-p bug Report



I needed some wierd shaped buttons (eg one shaped like America, one for
Mexico, ...),
so I thought I would implement a *region-button-dialog-item*.

I shadowed point-in-item-p to call (point-in-region-p my-region where).
Unfortunately, the dialog-item-click-event-handler for *dialog-item* is
called when point-in-item-p is true, but it in turn does NOT call
point-in-item-p at mouse-up to check if dialog-item-action should be
called.

I suspected that it was doing point-in-rect-p directly instead of calling
point-in-item-p :-(
While writing up a sample file to show this bug, I found an even more
interesting phenomenon.
If one shadows point-in-item-p and calls usual-point-in-item-p, then the
dialog-item-action is called IMMEDIATELY on mouse-down rather than on
mouse-up.  I am baffled by this.  Note that this is true even if
point-in-item-p JUST calls usual-point-in-item-p and does NOTHING else.

I'm going to try writing my own dialog-item-click-event-handler to track
the mouse and do all the stuff that dialog-item-click-event-handler should
be doing, but this raises some questions:  Since there is no way of
knowing, a priori, what a button's shape will be, I need the button to have
an invert object-function to invert the color of the button while the mouse
is down inside the button that can be shadowed by the various sub-classes
of buttons.  A *button-dialog-item* does NOT just invert its rect, because
the white-space outside the border does not get inverted even though it IS
a part of the button as far as clicking goes :-(.  So how do I invert JUST
the area inside the button outline.  Or is there a predefined invert
function for *button-dialog-item*?  I couldn't find one using inspect or
apropos.

Here is the previously mentioned code, for whatever it's worth:
Of the four buttons, only the standard OK button works properly.  The
others refuse to call dialog-item-action, or call it on mouse-down.

(defobject *test-region-dialog-item* *button-dialog-item*)

(defobfun (exist *test-region-dialog-item*) (init-list)
  (usual-exist init-list)
  (have 'my-region)
)

(defobfun (add-self-to-dialog *test-region-dialog-item*) (dialog)
  (declare (object-variable my-region))
  (usual-add-self-to-dialog dialog)
  (setq my-region (new-region))
  (set-rect-region my-region
                   (add-points (dialog-item-position) (dialog-item-size))
                   (add-points (add-points (dialog-item-position)
                                           (dialog-item-size)
                               )
                               (dialog-item-size)
  )                )
)

(defobfun (remove-self-from-dialog *test-region-dialog-item*) ()
  (declare (object-variable my-region))
  (dispose-region my-region)
  (usual-remove-self-from-dialog)
)

(defobfun (point-in-item-p *test-region-dialog-item*) (point)
  (declare (object-variable my-region))
  (point-in-region-p my-region point)
)

(defobfun (dialog-item-click-event-handler *test-region-dialog-item*)
(where)
  (format t "Region Click Event~%")
  (usual-dialog-item-click-event-handler where)
)

(defobfun (dialog-item-action *test-region-dialog-item*) ()
  (format t "Region Action~%")
  (usual-dialog-item-action)
)

(defobfun (dialog-item-draw *test-region-dialog-item*) ()
  (declare (object-variable my-region))
  (with-focused-view my-dialog
    (_InverRgn :ptr my-region)
) )

(defobject *test-button-dialog-item* *button-dialog-item*)

(defobfun (dialog-item-click-event-handler *test-button-dialog-item*)
(where)
  (format t "Button click-event.~%")
  (usual-dialog-item-click-event-handler where)
)

(defobfun (dialog-item-action *test-button-dialog-item*) ()
  (format t "Button action.~%")
  (usual-dialog-item-action)
)

(defobject *second-test-region-dialog-item* *dialog-item*)

(defobfun (exist *second-test-region-dialog-item*) (init-list)
  (usual-exist init-list)
  (have 'my-region)
)

(defobfun (add-self-to-dialog *second-test-region-dialog-item*) (dialog)
  (declare (object-variable my-region))
  (usual-add-self-to-dialog dialog)
  (setq my-region (new-region))
  (set-rect-region my-region
                   (add-points (dialog-item-position) (dialog-item-size))
                   (add-points (add-points (dialog-item-position)
                                           (dialog-item-size)
                               )
                               (dialog-item-size)
  )                )
)

(defobfun (remove-self-from-dialog *second-test-region-dialog-item*) ()
  (declare (object-variable my-region))
  (dispose-region my-region)
  (usual-remove-self-from-dialog)
)

(defobfun (point-in-item-p *second-test-region-dialog-item*) (point)
  (declare (object-variable my-region))
  (or (point-in-region-p my-region point)
      (usual-point-in-item-p point)
) )

(defobfun (dialog-item-click-event-handler
*second-test-region-dialog-item*) (where)
  (format t "Second Region Click Event~%")
  (usual-dialog-item-click-event-handler where)
)

(defobfun (dialog-item-action *second-test-region-dialog-item*) ()
  (format t "Second Region Action~%")
  (usual-dialog-item-action)
)

(defobfun (dialog-item-draw *second-test-region-dialog-item*) ()
  (declare (object-variable my-region))
  (with-focused-view my-dialog
    (_InverRgn :ptr my-region)
) )

(defobject *third-test-region-dialog-item* *dialog-item*)

(defobfun (exist *third-test-region-dialog-item*) (init-list)
  (usual-exist init-list)
  (have 'my-region)
)

(defobfun (add-self-to-dialog *third-test-region-dialog-item*) (dialog)
  (declare (object-variable my-region))
  (usual-add-self-to-dialog dialog)
  (setq my-region (new-region))
  (set-rect-region my-region
                   (add-points (dialog-item-position) (dialog-item-size))
                   (add-points (add-points (dialog-item-position)
                                           (dialog-item-size)
                               )
                               (dialog-item-size)
  )                )
)

(defobfun (remove-self-from-dialog *third-test-region-dialog-item*) ()
  (declare (object-variable my-region))
  (dispose-region my-region)
  (usual-remove-self-from-dialog)
)

(defobfun (point-in-item-p *third-test-region-dialog-item*) (point)
  (usual-point-in-item-p point)
)

(defobfun (dialog-item-click-event-handler *third-test-region-dialog-item*)
(where)
  (format t "Third Region Click Event~%")
  (usual-dialog-item-click-event-handler where)
)

(defobfun (dialog-item-action *third-test-region-dialog-item*) ()
  (format t "Third Region Action~%")
  (usual-dialog-item-action)
)

(defobfun (dialog-item-draw *third-test-region-dialog-item*) ()
  (declare (object-variable my-region))
  (with-focused-view my-dialog
    (_InverRgn :ptr my-region)
) )


(oneof *dialog*
       :window-size #@(300 250)
       :dialog-items
       (list (oneof *test-region-dialog-item*
               :dialog-item-position #@(4 4)
               :dialog-item-size #@(50 50)
             )
             (oneof *test-button-dialog-item*
               :dialog-item-position #@(120 4)
               :dialog-item-size #@(50 50)
             )
             (oneof *second-test-region-dialog-item*
               :dialog-item-position #@(4 120)
               :dialog-item-size #@(50 50)
             )
             (oneof *third-test-region-dialog-item*
               :dialog-item-position #@(120 120)
               :dialog-item-size #@(50 50)
             )
       )
)

"TANSTAAFL" Rich lynch@aristotle.ils.nwu.edu