[comp.sys.mac.programmer] Routines to InsertMenuItem

cpyang@ccnysci.UUCP (Chao Ping Yang) (11/30/88)

First of all many thanks to the folks who helped
me out on SetIndString, and now I have working routines
SetIndString, AddIndString and RmvIndString...

But do I have to do the same sort of things for the Menu Items?
Has anybody already written this or there is a ToolBox routine
that I am not aware of?  What I mean is how do I work on the
Menu Items more than SetItem and AppendMenu, like I would like
to Insert and remove ...

==Chaoping

rick@Jessica.stanford.edu (Rick Wong) (12/01/88)

In article <1020@ccnysci.UUCP> cpyang@ccnysci.UUCP (Chao Ping Yang) writes:
>
>					. . . how do I work on the
>Menu Items more than SetItem and AppendMenu, like I would like
>to Insert and remove ...
>
>==Chaoping

From Inside Mac IV, pp. 55-56:

PROCEDURE InsMenuItem(theMenu: MenuHandle; itemString: Str255;
		afterItem: INTEGER);

InsMenuItem inserts an item or items into the given menu where specified by
the afterItem parameter.  If afterItem is 0, the items are inserted before
the first menu item; if it's the item number of an item in the menu, they're
inserted after that item; if it's equal to or greater than the last item
number, they're appended to the menu.

The contents of itemString are parsed as in the AppendMenu procedure.  Mul-
tiple items are inserted in the reverse of their order in itemString.


PROCEDURE DelMenuItem(theMenu: MenuHandle; item: INTEGER);

DelMenuItem deletes the specified item from the given menu.


Rick Wong.

ech@poseidon.ATT.COM (Edward C Horvath) (12/03/88)

From article <1020@ccnysci.UUCP>, by cpyang@ccnysci.UUCP (Chao Ping Yang):
> ...Menu Items?
> Has anybody already written this or there is a ToolBox routine
> that I am not aware of?  What I mean is how do I work on the
> Menu Items more than SetItem and AppendMenu, like I would like
> to Insert and remove ...

See IM 4, p55ff: the 128K and later ROMS have
	PROCEDURE InsMenuItem (theMenu: MenuHandle; itemString: Str255;
		afterItem: INTEGER);
and
	PROCEDURE DelMenuItem (theMenu: MenuHandle; item: INTEGER);

Your favorite compiler ought to support these.  Traps if you need for asm,
are A826 and A952 respectively.

=Ned Horvath=

liberte@zaphod.ncsa.uiuc.edu (12/08/88)

Here is another IM error concerning menus.  (I lost the address of the
guy at Apple who is collecting these.)

IM V-241 PopUpMenuSelect, the result is a pascal integer (short) not a
longint.

Dan LaLiberte
National Center for Supercomputing Applications
liberte@ncsa.uiuc.edu

mjohnson@Apple.COM (Mark Johnson) (12/08/88)

In article <900013@zaphod> liberte@zaphod.ncsa.uiuc.edu writes:
>
>Here is another IM error concerning menus.  (I lost the address of the
>guy at Apple who is collecting these.)
>
>IM V-241 PopUpMenuSelect, the result is a pascal integer (short) not a
>longint.
>
>Dan LaLiberte
>National Center for Supercomputing Applications
>liberte@ncsa.uiuc.edu

Thanks Dan.  IM errors should be sent to fish@apple.com.


Mark B. Johnson                                           AppleLink: m.johnson
Developer Technical Support                         domain: mjohnson@Apple.com
Apple Computer, Inc.            UUCP: {amdahl,decwrl,sun,voder}!apple!mjohnson

earleh@eleazar.dartmouth.edu (Earle R. Horton) (12/09/88)

In article <900013@zaphod> liberte@zaphod.ncsa.uiuc.edu writes:
>
...
>IM V-241 PopUpMenuSelect, the result is a pascal integer (short) not a
>longint.
>
This is wrong.  The result of PopUpMenuSelect is a longint, with the
Menu ID in the high word, and the item number in the low word.  It is
in the same format as the result of MenuSelect.
Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755
(603) 643-4109
Graduate student.

jmpdude@Apple.COM (Mike Puckett) (12/11/88)

In article <900013@zaphod> liberte@zaphod.ncsa.uiuc.edu writes:
>
>Here is another IM error concerning menus.  (I lost the address of the
>guy at Apple who is collecting these.)
>
>IM V-241 PopUpMenuSelect, the result is a pascal integer (short) not a
>longint.
>
>Dan LaLiberte
>National Center for Supercomputing Applications
>liberte@ncsa.uiuc.edu


Wait a second!  PopupMenuSelect *DOES* return a long (as documented), not
a short.  The hi-order part of the long contains the PopUpMenu's menu ID,
and the lo-order part of the long contains the selected menu's item number.

Mike Puckett
jmpdude@apple.com

liberte@zaphod.ncsa.uiuc.edu (12/13/88)

> >IM V-241 PopUpMenuSelect, the result is a pascal integer (short) not a
> >longint.
> >
> This is wrong.  The result of PopUpMenuSelect is a longint, with the
> Menu ID in the high word, and the item number in the low word.

Sorry folks.  I got this error report from someone else who I used to
trust :-).  Anyway, I hope Apple is checking these documentation error
reports as well as (or better than) they check software.  Correct
documentation (including known bugs) is very important.

dan