[comp.sys.mac.programmer] THINK C Class Library Questions

kim@feynman.valid.com (Kim Helliwell) (06/06/91)

I am working on an application in THINK C, and finally got to the point
of adding some new menu commands.  However, I can't seem to get the
menu items I've added to be enabled.  I have RTFM, and I think I'm doing
things correctly.  I added an UpdateMenus() method to my own CDocument
class, but the routine doesn't get called.  This may be because I'm not
correctly setting gGopher.  In short, I'm confused about when (or even
whether) I have to set gGopher, what I should set it to, and how far down 
in my hierarchy of classes I can or should put UpdateMenus method 
overrides, and so on.  Has anyone been through this so you can help me?

Incidently, the example code doesn't seem to me to be too enlightening on
these points, either.


"Never let work interfere with your reasons for working."

Kim Helliwell

guelzow@ccu.umanitoba.ca (Andreas J. Guelzow) (06/06/91)

In article <548@valid.valid.com> kim@feynman.valid.com (Kim Helliwell) writes:
>I am working on an application in THINK C, and finally got to the point
>of adding some new menu commands.  However, I can't seem to get the
>menu items I've added to be enabled.  I have RTFM, and I think I'm doing
>things correctly.  I added an UpdateMenus() method to my own CDocument
>class, but the routine doesn't get called.  This may be because I'm not
>correctly setting gGopher.  In short, I'm confused about when (or even
>whether) I have to set gGopher, what I should set it to, and how far down 
>in my hierarchy of classes I can or should put UpdateMenus method 
>overrides, and so on.  Has anyone been through this so you can help me?

It's really pretty straight forward. gGopher should really be the
lowest ranking bureaucrat that should receive the commands. Quite
often it will be the MainPane of the active Window. All commands are
send to the gGopher and passed along the chain of commands until they
are being handled. Many commands you may want to handle at the
document level (which usually is the supervisor of the MainPane). The
UpdateMenus method is called along the same line of command: that
object should activate a menu command that wants to handle it if the
command is being chosen. This may mean that the same menu command
could be activated by different objects. The object lower in the chain
will have the first chance to reply.

I hope that helped.


-- 
Andreas J. Guelzow                       <guelzow@ccu.umanitoba.ca>
Department of Mathematics & Astronomy        University of Manitoba