[comp.sys.mac.programmer] CommToolbox/Think Class Library Event Questions

tj@cs.ucla.edu (Tom Johnson) (04/18/91)

Hello all,


I'm working on a CommToolBox application using the Think Class
Library, and I've hit upon a major stumbling block.  I'll explain
my problem, and hopefully someone out there has some ideas or has
tried to do something similar in the past.

Problem:
   Part A:   When using an CTB Connection and/or terminal, the
application must call a few routines to make sure that the CTB
gets events.  Some are pretty easy to handle with TCL--I simply
created a subclass of CChore to handle the CMIdle and TMIdle
calls.  But a couple are not so simple.  Most specifically
CMEvent, TMEvent, and FTEvent.  These calls allow the various CTB
routines to handle events meant for them.  To quote fromt he
documentation for CMEvent:
   "When your application receives an event, it should check if
the refcon of the window is a tool's ConnHandle.  Such an event
occurs, for example, when the user clicks a button in a dialog
box displayed by the connection tool.  If it does belong to a
connection tool's window, your application should call CMEvent."
  The TCL documentation states recommends against modifying the
TCL source, but states "If you need to keep track of events as
the Event Manager gets them, it's probably easier to modify the
CSwitchboard class to do this than to create a subclass."  It
sounds like this is what I want to do.  Any comments?



   Part B:  It appears that the TCL stores in a window's refCon
field a pointer to the CWindow object.  This is gonna make things
a bit more difficult.  I'll have to grab the refCon of the
window, and then try to figure out if the refCon is a CWindow *,
a ConnHandle, a TermHandle, or an FTHandle.  I suppose I can
create a CList which contains a list of the CTB handles I create,
and each time through the event loop I could check to see if the
refCon of the FrontWindow is one of the handles in the list, but
this seems rather slow and clumsy.  I don't like the idea of
doing that much processing every time through the event loop.  Or
am I being paranoid?  Does anybody have any better ideas for a
way to handle this?

To recap my questions:  Should I go ahead and just modify
CSwitchboard to handle the CMEvent, TMEvent and FTEvent routines?
 How should I determine whether to call the CMEvent, TMEvent, or
FTEvent? Does anybody have some sample source code for the
CommToolbox?

Thanks-

Tom 
-- 
Tom Johnson             "I put this moment.............................here
tj@cs.ucla.edu           I put this moment......................here
                         I put this moment--
                                              Over here!"        (Kate)