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

Re: Getting stuff to HAPPEN while in an event handler



In article <crone-130395123921@crone.ils.nwu.edu>, crone@ils.nwu.edu
(Chris Crone) wrote:

> I'd like to be able to add a pop-up menu from the view click event handler,
> and allow the user to select from it, all in the same click/drag (not by
> making the popup a subview, though).  Has anyone done this?  The way I see
> it, menus do something similar (i.e. add some stuff to themselves as soon
> as the user clicks, etc), but I haven't been able to find the  methods used
> there.

(require 'pop-up-menu)

(defclass pop-up-window (window)
  ((pop-up :initform 
           (make-instance 'pop-up-menu
             :view-size #@(0 0)
             :menu-items
             (list
              (make-instance 'menu-item
                :menu-item-title "item one"
                :menu-item-action #'(lambda ()
                                      (print 1)))))
           :accessor puw-popup))
  )
             
(defmethod view-click-event-handler ((me pop-up-window) where)
  (set-view-position (puw-popup me) where)
  (set-view-container (puw-popup me) me)
  (unwind-protect 
    (menu-select (puw-popup me) nil)
    (set-view-container (puw-popup me) nil)
    )
  )

#|
(make-instance 'pop-up-window)
|#

 Karsten