[comp.sys.mac] enabling the correct entries in the 'Edit' menu

jva@cadnetix.UUCP (Joe VanAndel) (09/22/87)

I have a question about enabling/disabling the standard 
'cut/copy/paste/clear' menu items under the 'Edit' menu.  If
I have an application that has multiple windows, where one window
supports 'cut/paste' and another doesn't, and I need to support
desk-accessories that need the 'Edit' menu, what do I do?  I
don't want menu entries that are non-functional to be enabled.
I have discovered how to determine that a desk-accessory window had
been activated or de-activated, and enabled/disabled the menu
items appropriately, but then I discovered that I had missed the
case of the desk-accesssory being closed, while its window was active.

I've probably gone down a blind alley, but could someone tell me
the right way?

Thanks in advance!
-- 
	Joe VanAndel  		UUCP:		hao!ico!cadnetix!jva
	Cadnetix Corp.		  		jva@cadnetix.UUCP
	5757 Central Ave.
	Boulder, CO 80301	Voice:		303-444-8075

lsr@apple.UUCP (09/24/87)

In article <876@cadnetix.UUCP> jva@cadnetix.UUCP (Joe VanAndel) writes:
>
>I have discovered how to determine that a desk-accessory window had
>been activated or de-activated, and enabled/disabled the menu
>items appropriately, but then I discovered that I had missed the
>case of the desk-accesssory being closed, while its window was active.

In MacApp we check for an active desk accessory after each event.  You do
this by looking at the window kind field of the FrontWindow.  DA Windows
have a negative window kind (it is the DA refnum).  If FrontWindow returns
NIL, then there are no windows open.

-- 
Larry Rosenstein

Object Specialist
Apple Computer

AppleLink: Rosenstein1
UUCP:  {sun, voder, nsc, mtxinu, dual}!apple!lsr
CSNET: lsr@Apple.com

dalea@fai.UUCP (Dale M. Arends) (09/24/87)

In article <876@cadnetix.UUCP> jva@cadnetix.UUCP (Joe VanAndel) writes:
>I have a question about enabling/disabling the standard 
>'cut/copy/paste/clear' menu items under the 'Edit' menu.  If
>I have an application that has multiple windows, where one window
  [deleted]
>I've probably gone down a blind alley, but could someone tell me
>the right way?
>
>Thanks in advance!
>-- 
>	Joe VanAndel  		UUCP:		hao!ico!cadnetix!jva

I have a program that has the same requirements.  The way I solved
it, and I don't guarantee that this is the best way, is to keep an
eye on the value returned by FrontWindow().  If it points to one
of my windows that needs the Edit items or a desk accessory, I
make sure that the Edit items are enabled.  Otherwise, I disable
the Edit items.

Additionally, (insurance you know) I make a practice of enabling the
Edit items before launching a desk accessory and checking FrintWindow()
(oops, FrontWindow()) when Close is selected from the menubar.

-- 
--
		Dale M. Arends  (Fujitsu America Inc., San Jose, Calif.)
		seismo!amdahl!fai!dalea

The opinions expressed herein do not necessarily reflect those of my employer.
They are entirely my own if they make sense and I disavow them if they don't.