-- card: 3735 from stack: in.1 -- bmap block id: 13302 -- flags: 0000 -- background id: 3468 -- name: -- part 1 (button) -- low flags: 00 -- high flags: A004 -- rect: left=9 top=106 right=125 bottom=70 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Example ----- HyperTalk script ----- on mousedown put the mouseloc into myPlace put item 1 of myPlace - 20 into horiz put item 2 of myPlace - 10 into vert get PopUpMenu("For;a;disk;catalog;of;BMUG's;stack;library;"& "Send;$3;To;BMUG;1442A;Walnut;#62;Berkeley;CA;94709", 5, vert, horiz) put "You chose item" && it end mousedown -- part contents for background part 1 ----- text ----- PopUpMenu( MenuItems, CheckedItem, Top, Left ); XFCN returns a number associated with item number chosen. Menuitems - string of items which correspond to a line item in the menu. CheckedItem - displays a check next to item referenced by the items's line #. Top, Left - coordinates of menu placement ------------------ example: on mousedown put the mouseloc into myPlace put item 1 of myPlace - 20 into horiz put item 2 of myPlace - 10 into vert get PopUpMenu("For;a;disk;catalog;of;BMUG's;stack;library;"&¬ "Send;$3;To;BMUG;1442A;Walnut;#62;Berkeley;CA;94709", 5, vert, horiz) put "You chose item" && it end mousedown ------------------- CODE: To compile and link using Macintosh Programmer's Workshop 2.0 execute the following: pascal -w PopUp.p link -o HyperCommands -rt XFCN=0 -sn Main=PopUpMenu PopUp.p.o I wish to thank Dewi Williams and Larry Rosenstein for thier initial information and example. Andrew Gilmartin Brown University } UNIT PopUpUnit; INTERFACE USES MemTypes, QuickDraw, OSIntf, ToolIntf, HyperXCmd; PROCEDURE EntryPoint(paramPtr: XCmdPtr); IMPLEMENTATION PROCEDURE PopUpMenu(paramPtr: XCmdPtr); FORWARD; PROCEDURE EntryPoint(paramPtr: XCmdPtr); BEGIN PopUpMenu(paramPtr) END { entrypoint } ; PROCEDURE PopUpMenu; CONST MenuID = 128; VAR Menu: MenuHandle; MenuItems: Str255; CheckedItem, SelectedItem, Top, Left: LongInt; {$I XCmdGlue.inc} PROCEDURE ParamToMenuItems(Param: Handle; VAR MenuItems: Str255); VAR Index: integer; BEGIN ZeroToPas(Param^, MenuItems); FOR Index := 1 TO length(MenuItems) DO IF MenuItems[Index] = ',' THEN MenuItems[Index] := ';'; END { ParamToMenuItems } ; FUNCTION ParamToNum(Param: Handle): LongInt; VAR Str: Str255; BEGIN ZeroToPas(Param^, Str); ParamToNum := StrToNum(Str); END { ParamToNum } ; FUNCTION NumToParam(Num: LongInt): Handle; VAR Str: Str31; BEGIN Str := NumToStr(Num); NumToParam := PasToZero(Str) END { NumToParam } ; BEGIN WITH paramPtr^ DO BEGIN { Create the PopUp menu } ParamToMenuItems(Params[1], MenuItems); CheckedItem := ParamToNum(Params[2]); Menu := NewMenu(MenuID, ''); AppendMenu(Menu, MenuItems); CheckItem(Menu, CheckedItem, true); InsertMenu(Menu, - 1); { Get Menu Position } Top := ParamToNum(Params[3]); Left := ParamToNum(Params[4]); { Get Menu Selection } SelectedItem := PopUpMenuSelect(Menu, Top, Left, CheckedItem); { Tidy up } DeleteMenu(MenuID); DisposeMenu(Menu); { Return the selection } returnValue := NumToParam(LoWord(SelectedItem)) END END { PopUpMenu } ; END. { PopUp Unit } -- part contents for background part 2 ----- text ----- PopUpMenu -- part contents for background part 4 ----- text ----- PopUpMenu(, , , ) -- part contents for background part 9 ----- text ----- XFCN -- part contents for background part 8 ----- text ----- Andrew Gilmartin