3.4.3 Active regions
with-mouse-methods-preemptedallows you to specify which active regions are disabled while the argument forms are executed, as follows:
nil, all active regions are disabled.
with-mouse-methods-preempted-globallydisables all active regions except the specified active region and expands the active area of the region to include the entire screen. Hence, a mouse event in any area of the root viewport is treated as though it happened in the specified region.
When the argument forms to either of these macros have executed, all active regions return to the state they were in before the macro invocation.
In this example, a mouse click in the given window displays a pop-up menu. An active region method in the given window triggers the display of the pop-up menu. Since displaying the pop-up window requires mouse input inside the given window's input process, you must display the pop-up menu in a separate process.
To prevent active region methods from other windows from triggering when you click the mouse in the first window, you must preempt other mouse methods for the given window.
(defun menu-demo (window) (let ((x 10) (y 30) (font *default-font*) (string "click here") (popup-menu (make-pop-up-menu '(choice1 choice2))))
;; Execute only this window's active region methods. (with-mouse-methods-preempted window (stringblt window (make-position x (1- y)) font string) (let ((region (make-region :x x :y (- y (font-height font)) :width (string-width string font) :height (font-height font))))
;; Make the active region around the string. (make-active-region region :bitmap window :mouse-documentation "Right: pop up menu" :mouse-enter-region ; Outline the string. #'(lambda (viewport region event x y) (declare (ignore event x y)) (draw-region-rect region viewport)) :mouse-exit-region ; Remove outline. #'(lambda (viewport region event x y) (declare (ignore event x y)) (draw-region-rect region viewport)) :mouse-click ; Pop up menu. #'(lambda (viewport region event x y) (declare (ignore event)) (make-process ; Must start a new process here. :name "popup menu process" :function #'(lambda () (print (pop-up-menu-choose popup-menu))))))))))
;; Invoke the function. (menu-demo *window*)
Generated with Harlequin WebMaker