[comp.sys.mac.programmer] Simulating a Dialog with the WM

bowman@reed.UUCP (Eric Bowman) (04/10/90)

My apologies to Tim who will probably find this question unworthy of an
answer ;-)

I'm trying to use the Window Manager to create a non-modal dialog-like
window.  I'm trying to implement some TE items, but I can't figure out how
to implement autoscrolling either while selecting text or scrolling with
the cursor keys.

IM4 describes TEAutoView, TEPinScroll, and TESelView.  I am using TEAutoView
to (I thought) activate the automatic scrolling, but this doesn't seem to
be enough.  I've been trying to figure out how the Dialog Manager does it,
and TEKey seems to be calling TEPinScroll at the appropriate time, but
I can't seem to get this to work.  Nor can I find anything helpful in the
TN's, nor does any of the sample code I have deal with this.

Any help would be greatly appreciated,
BoBo
bowman@reed.{bitnet,UUCP,edu}

minow@mountn.dec.com (Martin Minow) (04/13/90)

In article <14661@reed.UUCP> bowman@reed.UUCP (Eric Bowman) asks about
simulating a TextEdit item using the Window Manager, and is stuck trying
to figure out autoscrolling.

Try looking through the source code to my TextEdit clone, as published
in MacTutor Feb and March 1990.  (The code you want is in March, but there's
useful stuff in February, too.)  This describes how autoscrolling works in
lurid detail.

>I can't seem to get this to work.  Nor can I find anything helpful in the
>TN's, nor does any of the sample code I have deal with this.

Welcome to the wonderful world of Macintosh programming.  Are you sure there
isn't anything useful in the latest batch of sample code?  Also, you should
find some examples in MacTutor.

The easiest way to handle scrolling is to have a single "scroll" routine
that is called with the amount and direction (or a signed amount value).
There are only a handful of cases:

-- Click in the scroll bar:  get the part of the scroll bar and call the
   scroller with +/- one line, +/- one page, or the result of TrackControl
   if inThumb: lots of examples in MacTutor.

-- Up/down arrow: call the scroller with +/- one line -- similar for page
   up/down.  Home and End are easy, too.  Note that the arrow keys have
   different values for the different keyboards: see IM-V.

-- Autoscroll: plug into the TextEdit clickLoop callback; if the mouse goes
   out of the viewRect, find the "distance" between the mouse and the proper
   edge of the viewRect (i.e. if the mouse is above the viewRect, you
   want to scroll down), and call the scroller.

Good luck.

Martin Minow
minow@thundr.enet.dec.com