[comp.sys.mac.programmer] Menu Manager Bug...?

singer@endor.harvard.edu (Rich Siegel) (07/23/88)

Consider the following code:

	AppendMenu(SpecialMenu, ' '); {create a dummy menu item}
	SetItem(SpecialMenu, windowCount + 6, wPeek^.TitleHandle^^);

If the window's name begins with a dash (-), the entire menu item is
a gray line. This would be correct behavior if the string was passed
to AppendMenu, but NOT for sSetItem. Inside Macintosh (Volume 1, page 357)
says:

	"SetItem changes the text of the given item to itemString. It doesn't
recognize the metacharacters used in AppendMenu; if you include them in
ItemString, they will appear in the text of the menu item."

Unfortunately, I didn't notice whether this behavior appeared when I updated
my system to the 6.0 distribution.

My configuration is as follows:

	Macintosh Plus
	2.5 MB
	Radius Accelerator (version 1.8 ROMs)
	System 6.0

Is this a new bug, a "feature", or am I completely off base?

Thanks for any insights...

		--Rich

Rich Siegel
THINK Technologies

Rich Siegel
Quality Assurance Technician
THINK Technologies Division, Symantec Corp.
Internet: singer@endor.harvard.edu
UUCP: ..harvard!endor!singer
Phone: (617) 275-4800 x305

wrs@Apple.COM (Walter Smith) (07/23/88)

The '-' is not really an AppendMenu metacharacter.  When the menu
defproc is about to draw a menu item, it looks at the first character
of the item string.  If it's a '-', a gray line is drawn; otherwise
the item string is drawn.  I'm afraid there's not much you can do
about it other than writing your own defproc or inserting a small
nonprinting character before items beginning with a '-'.

By the way, it's done this since 1984.

- Walt
--
Walter Smith	    Apple Computer	wrs@apple.com, ..!sun!apple!wrs
		    Special Projects	>>new>>	(408) 973-5892
Disclaimer:
Anyone who thinks I might be representing Apple Computer, Inc. in any
official capacity on Usenet, of all places, has a serious attitude problem.

darin@Apple.COM (Darin Adler) (07/23/88)

In article <5005@husc6.harvard.edu> singer@endor.UUCP (Rich Siegel) writes:
> ...
>
> If the window's name begins with a dash (-), the entire menu item is
> a gray line. This would be correct behavior if the string was passed
> to AppendMenu, but NOT for sSetItem. Inside Macintosh (Volume 1, page 357)
> says:
> 
> 	"SetItem changes the text of the given item to itemString. It doesn't
> recognize the metacharacters used in AppendMenu; if you include them in
> ItemString, they will appear in the text of the menu item."
> 
> ...
>
> Is this a new bug, a "feature", or am I completely off base?

If you read the section for AppendMenu you will see that the hyphen (-) is
*not* one of the meta-characters in the meta-character chart. It is mentioned
earlier in the paragraph:

	"If it begins with a hyphen (-), the item will be a dividing
	 line across the width of the menu."

So this is just a misunderstanding (which might have been averted if the above
had been repeated in the section describing SetItem).
--
Darin Adler					       AppleLink: Adler4
UUCP: {sun,voder,nsc,mtxinu,dual}!apple!darin	  CSNET: darin@Apple.com

earleh@eleazar.dartmouth.edu (Earle R. Horton) (07/24/88)

In article <5005@husc6.harvard.edu> singer@endor.UUCP (Rich Siegel) writes:
>Consider the following code:
>
>	AppendMenu(SpecialMenu, ' '); {create a dummy menu item}
>	SetItem(SpecialMenu, windowCount + 6, wPeek^.TitleHandle^^);
>
>If the window's name begins with a dash (-), the entire menu item is
>a gray line. This would be correct behavior if the string was passed
>to AppendMenu, but NOT for sSetItem. Inside Macintosh (Volume 1, page 357)
>says:
...

The described behavior occurs with System 2.0 running on a Mac Plus,
and with all the 4.x systems, so it is nothing new.  I think that the
behavior is "correct" according to the documentation, but that the
documentation is vague.  Actually, the documentation is terrible
(ptui!).  Anybody at Apple reading this?

My interpretation is that the minus sign as the start of a menu item's
text means "Draw the gray line, just draw it." and that the effect of
the "meta-characters" is in some sense different from the effect of
the minus sign.  Looking at it another way, meta-characters change
some attribute of the menu item's text, while the minus sign specifies
that the desired menu item is the gray line.  I suggest quoting the
text, making the menu item something like " '-file1' " or perhaps
putting a space in front of it.

This is actually a fairly common situation, as in the case of any
program which uses a menu to switch between named document windows.
It happens in MicroSoft Word 3.02, and probably in all Macintosh
applications which have a menu consisting of window or file names
which could start with '-'.  It happens in MultiFinder's menu for open
applications if you rename an application to start with '-' and then
launch it under MultiFinder.

I suggest that this is a "feature" of the present Menu Manager, and
that you will have to code for it or you will get a "bug" in your
program.

Earle R. Horton.  H.B. 8000, Dartmouth College, Hanover, NH 03755

lippin@chex.berkeley.edu (The Apathist) (07/24/88)

In article <5005@husc6.harvard.edu> singer@endor.UUCP (Rich Siegel) writes:

> If the window's name begins with a dash (-), the entire menu item is
> a gray line.

There's one easy near-workaround for this: instead of starting the
menu with a hyphen (i.e., the other thing on the underscore key), use
a dash, which is option-hyphen.  The dash is a pixel or two longer
than the hyphen in Chicago font, but the difference is easy to
overlook.

(The reason for the difference is that in fonts meant to be printed,
the dash is notably longer than the hyphen, as it should be in a
manuscript.)

						--Tom Lippincott
						..ucbvax!math!lippin

	"Please do not defeat this important saftey feature."

erics@eleazar.dartmouth.edu (Eric Schlegel) (07/24/88)

In article <5005@husc6.harvard.edu> singer@endor.UUCP (Rich Siegel) writes:
>Consider the following code:
>
>	AppendMenu(SpecialMenu, ' '); {create a dummy menu item}
>	SetItem(SpecialMenu, windowCount + 6, wPeek^.TitleHandle^^);
>
>If the window's name begins with a dash (-), the entire menu item is
>a gray line. This would be correct behavior if the string was passed
>to AppendMenu, but NOT for SetItem. Inside Macintosh (Volume 1, page 357)
>says:
>
>	"SetItem changes the text of the given item to itemString. It doesn't
>recognize the metacharacters used in AppendMenu; if you include them in
>ItemString, they will appear in the text of the menu item."
>
>Is this a new bug, a "feature", or am I completely off base?
>
>Thanks for any insights...
>
>		--Rich

This is a "semi-feature" of the standard menu definition function. When 
AppendMenu sees an item beginning with a dash, it actually does nothing special
with the item and just inserts it literally into the menu record. When the
menu definition function draws the menu, however, it draws any line beginning
with a dash as a grayed-out line of dashes.

Given that this is the problem, you might try inserted an invisible character
before the dash so that the dash isn't the first character in the item.

Hope this helped...




Eric
------
Eric Schlegel                 |  DISCLAIMER: I'm just a poor college student,
eric.schlegel@dartmouth.edu   |  which means I'm not responsible for what I
eric.schlegel@dartvax.uucp    |  say and I can't pay you if you sue me anyway.

singer@endor.harvard.edu (Rich Siegel) (07/25/88)

In article <9482@dartvax.Dartmouth.EDU> earleh@eleazar.dartmouth.edu (Earle R. Horton) writes:
>This is actually a fairly common situation, as in the case of any
>program which uses a menu to switch between named document windows.
>It happens in MicroSoft Word 3.02, and probably in all Macintosh
>applications which have a menu consisting of window or file names
>which could start with '-'.  It happens in MultiFinder's menu for open
>applications if you rename an application to start with '-' and then
>launch it under MultiFinder.
>
>I suggest that this is a "feature" of the present Menu Manager, and
>that you will have to code for it or you will get a "bug" in your
>program.

	Sounds pretty bogus, if you ask me. :-)

	At any rate, I now special-case file names:

	title := wPeek^.TitleHandle^^;
	if title[1] = '-' then
		title := Concat(Chr(0), title);

	SeItem(SpecialMenu, WindowCount + 6, title);

This works fine, so now I guess I'm one of the few that does it right...

R.



Rich Siegel
Quality Assurance Technician
THINK Technologies Division, Symantec Corp.
Internet: singer@endor.harvard.edu
UUCP: ..harvard!endor!singer
Phone: (617) 275-4800 x305

ack@eleazar.dartmouth.edu (Andy J. Williams) (07/25/88)

In article <9488@dartvax.Dartmouth.EDU> erics@eleazar.dartmouth.edu (Eric Schlegel) writes:

>This is a "semi-feature" of the standard menu definition function.

> ...

>it draws any line beginning
>with a dash as a grayed-out line of dashes.

Actually, as far as I understand it, it draws any line starting with a "-"
as a line of dashes.  If you put a "(" in front of it, it THEN is a grayed
out line of dashes.

>eric.schlegel@dartvax.dartmouth.edu

-Andy


Andy J. Williams '90   |Ack Systems: ack@eleazar.dartmouth.edu|   _   /|
Software Development   +--------------------------------------+   \`o_O' ACK!
Kiewit Computation Ctr |Hello. Set $NAME='Iinigo Montoya' You |     ( )  /
Dartmouth College      |kill -9 my process.  Prepare to vi.   |      U

oster@dewey.soe.berkeley.edu (David Phillip Oster) (08/05/88)

In article <9482@dartvax.Dartmouth.EDU> earleh@eleazar.dartmouth.edu (Earle R. Horton) writes:
>This is actually a fairly common situation, as in the case of any
>program which uses a menu to switch between named document windows.
>It happens in MicroSoft Word 3.02, and probably in all Macintosh
>applications which have a menu consisting of window or file names
>which could start with '-'.  It happens in MultiFinder's menu for open

My Windows desk accessory handles this correctly. The NULL character is
always a zero-width blank, so it is perfect to use as a prefix in menus.

--- David Phillip Oster            --When you asked me to live in sin with you
Arpa: oster@dewey.soe.berkeley.edu --I didn't know you meant sloth.
Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu