[comp.sys.mac.programmer] Leading dashes in menu items.

freeman@argosy.UUCP (Jay R. Freeman) (06/11/90)

I need to create a menu item whose entire text consists merely of a
single minus sign.  Of course I can't just do that, because a single
minus sign is menu-manager meta-syntax for drawing a dashed line
across the menu.  And it appears that a leading minus sign is NOT one
of the meta-characters whose effect you can get around by using
SetItem (I think it is) on the actual text.

At the moment I am faking it satisfactorily by using option-minus-sign
instead, but I'm enough of a purist that the compromise bothers me.  I
expect I could write my own versions of lots of ToolBox routines
and/or definition functions, but I wondered if anyone knew of a better
hack?

(The menu is for on-line help with a programming-language interpreter;
that particular menu item will remind the user that yes indeedy, "-"
has to do with subtraction ...)

                                      -- Jay Freeman

       <canonical disclaimer -- all opinions herein are my own>

jholt@adobe.COM (Joe Holt) (06/11/90)

The standard Apple MDEF in systems 6.0.x will display a single dash as a
single dash if the dash item also has an icon or command key equivalent.
Unfortunately it does not test if the dash is the only character
(otherwise adding a space would be a nice work-around).

I think using an en-dash or em-dash is a good alternative.

joe holt

zben@umd5.umd.edu (Ben Cranston) (06/12/90)

In article <573@argosy.UUCP> freeman@cleo.UUCP (Jay R. Freeman) writes:

> I need to create a menu item whose entire text consists merely of a
> single minus sign.  Of course I can't just do that, because a single
> minus sign is menu-manager meta-syntax for drawing a dashed line
> across the menu.  And it appears that a leading minus sign is NOT one
> of the meta-characters whose effect you can get around by using
> SetItem (I think it is) on the actual text.

The trick I have always used in this case is to make the first character of
the menu item text a null (character code zero).  This is not displayed but
is enough to thwart the comparison in the menu manager.  The combination of
this and always using SetItem or whatever seems to work for me:

    string[0] = 2;
    string[1] = 0;
    string[2] = '-';
    SetItem(blatmenu,BMDASH,string);

Coding from memory without my trusty IM-I so don't flame if I goofed.  Cannot
remember where the null trick came from, might be IM, tech note, the network,
MacTutor, who knows...

Lest we belabor the obvious, make sure this doesn't faze any of your code
that might do a GetItem and look at the string, for you'll surely see the
null come right back to you!
-- 

"It's all about Power, it's all about Control
 All the rest is lies for the credulous"
-- Man-in-the-street interview in Romania one week after Ceaucescu execution.