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

Re: text edit in background window

Martin A. Kenner (makenner@mmm.com) wrote:
> I have a window that is not allowed to come to the front, but that 
> I would like to be able to allow the user to edit text in.

Certainly!  MCL is pretty flexible (although what you plan to do is not
encourage by the Macintosh Human Interface guidelines) :-)

> Is this possible?  

Yes again.

> It seems from the documentation that the window
> must come to the front in order for the key handler to be activated;
> I would really like to be able to work around this (I know it sounds 
> strange, but if I had the time and energy, the explanation would
> make it very clear!).

Not really -- I used a window-that-always-stay-at-the-back to implement the
Macintosh Desktop in a simulation of the Finder and it works real well ;-) 
Just use the attached code snippet to define a custom window class and you'll
get along fine.

JooFung Wong

P.S.  The attached code was sent to me by Nate Titterton.  It was a great help
to my project.  (THANKS Nate!)

From: nate@garnet.berkeley.edu (Nathaniel Titterton)
Subject: Re: Need window that always stays at the back
To: joofung@iss.nus.sg (Wong Joo Fung)
Date: Fri, 23 Jul 1993 08:39:12 -0700 (PDT)

We needed the same functionality (we even call our windows the
desktop and display windows -- scary).  After creating a new class of
window called a desktop, use this code...

(defconstant $event-part-code 16)

(defmethod window-event ((desk desktop))
  (let* ((event *current-event*)
         (what (pref event :eventRecord.what))
         (part-code (%get-word event $event-part-code))
    (if (eql what #$mouseDown)
      (cond ((point<= (subtract-points (view-size desk) #@(15 15))
                      (global-to-local desk (pref event
                      (view-size desk))
             (window-grow-event-handler desk (pref event
            ((eql part-code #$inContent)
             (with-focused-view desk
                desk (global-to-local desk (pref event
            ((eql part-code #$inDrag)
             (window-drag-event-handler desk (pref event

Hope it helps...