CLIM mail archive


problem selecting regions within regions

I'm seeing a general CLIM problem in my application that I've had a
lot of trouble reproducing in a simple example, but I finally have
one.  My application is an interactive graph editor.  Complex graphs
can be quite complex, with many nodes and edges on the screen at once.
We want the user to be able to select any node or edge for editing.
However, long diagonal edges (which therefore have large bounding
boxes) are often selectable exclusive of other nodes or edges that lie
within their bounding boxes.  That is, one long diagonal line on the
screen will be selectable, but rectangles or lines or text within the
bounding box of that line that should be mouse sensitive are not
(although if the long diagonal line is deleted, the contained graphics
is then sensitive).

The following is the one case I've been able to reproduce in
isolation.  I tried many other simple cases where CLIM was doing the
right thing.  So my general observation is that CLIM seems to make all
graphic elements sensitive most of the time, but not all of the time.
This particular example involves two lines, L1 and L2, for which the
bounding box of L2 is completely contained within the bounding box of
L1.  Again, I've seen this problem where L2 is instead a rectangle or
a circle or text.

Here is the program.  Look for the string "**" to see where the lines
are being drawn.  Simply moving the L2 upwards and out of the bounding
box of L1 makes it selectable.


; To run this, create a root window and then type  (ctest root)
; Then select the CMD-1 menu item.

(in-package 'clim-user)
(if (not (find-package 'gr))  ; Mimic SRI environment
    (make-package 'gr))

(clim:define-presentation-type square ())
(clim:define-presentation-type circle ())
(clim:define-presentation-type line ())

(define-application-frame test  ()
    ((main  :application
	    :incremental-redisplay t
	    :default-size :rest
	    :display-function 'display-main)
     (test-menu  :command-menu)
     (listener :interactor)))
  (:layout ((default (:column 1
			      (main :rest)
			      (test-menu .2)
			      (listener .15)
			      ))) )
     :inherit-from (user-command-table)
     (("EXIT"      :command cmd-exit)
      ("CMD1"  :command cmd-1)
      ("CMD2"  :command cmd-2)

(defmethod display-main ((frame test) stream)

  (clim:with-output-as-presentation (:object 7 :type 'line
				     :stream stream :single-box t)

;;***  In the current version of this code, the line drawn here is not
;; selectable.  But, if you swap the commented and the uncommented lines
;; here, the new position of the line renders it selectable.

    (CLIM:DRAW-LINE* stream 270 310 354 353 :LINE-THICKNESS 1)
;;;;    (CLIM:DRAW-LINE* stream 270 210 354 253 :LINE-THICKNESS 1)

  (clim:with-output-as-presentation (:object 8 :type 'line
				     :stream stream :single-box t)
    (CLIM:DRAW-LINE* stream 264 292 421 357 :LINE-THICKNESS 1)


(defun ctest (&optional (root gr::*grasper-root-window*)
  (let (frame))
    (setq *cache* 100)
    (setq *output-rec* nil)
    (setq frame (make-application-frame 'test
					:parent root
					:left 0
					:top 0
					:right 700
					:bottom 700))

    (run-frame-top-level frame)

(defun cmd-exit ()
  (clim:window-stack-on-bottom (clim:frame-top-level-window clim:*application-frame*))
  (clim:read-char-no-hang (clim:get-frame-pane clim:*application-frame*
  (frame-exit *application-frame*)

(defun cmd-1 ()
  (clim:accept '(or circle square line))

(defun cmd-2 ()
  nil )


Main Index | Thread Index