[comp.sys.mac.programmer] thePort and TENew

awd@dbase.UUCP (Alastair Dallas) (12/05/89)

The problem that had me tearing my hair out was incredibly simple as it
turned out.  I can keep it to myself, or I can share it at the risk of
appearing inexperienced.  Here it is--you won't care now, but maybe this
will settle into a niche at the back of your brain and when you trip over
this problem, you'll think of me.

I created an edit field with a call to TENew() and I set some text into
it.  Then, at update time, I call TEUpdate().  It didn't display anything.
I made sure that the port was set correctly at update time.  Still nothing.
I did a FrameRect() before the TEUpdate()--I got the rect, but no text.
I dumped the TERec--perfect.  I fiddled with the clipRgn.  Finally, in
desperation, I single-stepped through TEUpdate().

Do you know why I wasn't seeing text?  The port must be correct at TENew()
time, not TEUpdate().  You can be set to anything and still update your
TEs, but you have to make sure the port is right when you create the TE.
In most apps, you switch ports when you open windows and your calls to TENew()
come after that, so everything's fine.  In my case, the port was wrong at
init time, but I fixed it up later.

Hope it helps somebody somewhere sometime.

/alastair/