Path: utzoo!news-server.csri.toronto.edu!rutgers!rochester!pt.cs.cmu.edu!henry.ECE.CMU.EDU!hairston From: hairston@henry.ECE.CMU.EDU (David Hairston) Newsgroups: comp.sys.mac.programmer Subject: Re: Disabling menus when DA's are closed Message-ID: <12313@pt.cs.cmu.edu> Date: 10 Mar 91 21:26:33 GMT References: <1991Mar6.074201.13324@nada.kth.se> <6D6iy1w163w@shark.cs.fau.edu> Organization: Gaia II Lines: 36 [Eric Hicks writes in a message to All] [] Just a quick question that is quite probably rather simply solved. [] [] An application I'm writing never uses the edit menu while my [] main window is frontmost. (ie active) I've dimmed the menu, which [] is easily accomplished in ResEdit. My problem occurs with DA [] suppport. I can enable the menu when the DA comes up easily, i thought this had died but apparently there's still some confusion. if you are interested in a "simple" solution then model your event loop: while (! done) { adjustMenus(); WaitNextEvent(...); ... } adjustMenus() keeps your total menu interface uptodate with the current front window by noting the windowKind field, as mentioned before. adjustMenus() should be efficient and be able to determine the state of the menu bar and menus given the front window. adjustMenus() should also remember its previous state and only do work when the menu state changes (i.e. in the simplest case when the front window changes). keep in mind that when the menu bar changes state (i.e. the Edit menu is disabled) then you need to DrawMenuBar() to reflect the change. there may be situations where only the menus change and the menu bar doesn't. this approach is responsive, does not cause the menu bar to flicker, accurate with respect to being uptodate and easily managed and works for any type of front window. it seems to be a simple alternative. it also keeps your activeEvt and etc. handling simple. -dave- hairston@henry.ece.cmu.edu