Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!ut-emx!newman From: newman@ut-emx.UUCP (Dave Newman) Newsgroups: comp.sys.mac.programmer Subject: Re: List Manager Problem Message-ID: <11103@ut-emx.UUCP> Date: 9 Mar 89 16:27:26 GMT References: <11032@ut-emx.UUCP> <6704@hoptoad.uucp> Reply-To: newman@emx.UUCP (David Newman) Distribution: usa Organization: UTexas Computation Center, Austin, Texas Lines: 102 Tim Maroney suggested that I post my list initialization code and my filter proc to see if they were the problem. Here they are. Tim, I'll try your suggestion tonight. ------- procedure createList(var theWindow: grafPtr; itemRect: rect; numItems: integer; myStringList: stringListHandle; var itemList : listHandle); { code modified from ListTest by RDClark } const notDrawn = FALSE; noGrow = FALSE; noHScroll = FALSE; vScroll = TRUE; var dataBounds : Rect; cellSize : Point; firstRow, count : INTEGER; name : Str255; theCell : Cell; tempStringList : stringListHandle; begin TextFace([]); TextSize(12); TextFont(0); tempStringList := myStringList; SetRect(dataBounds, 0, 0, 1, 0); (* Specify initial 1x0 list*) SetPt(cellSize, 0, 0); (* calculate the cell size *) (* Create an empty item list, 0 rows by 1 column *) itemRect.right := itemRect.right - 16; (* Allow for scroll bars *) ItemList := LNew(itemRect,dataBounds,cellSize,0,theWindow,notDrawn, noGrow,noHScroll,vScroll); ItemList^^.selFlags := lDoHAutoscroll + lOnlyOne; (* use default options *) itemRect.right := itemRect.right + 16; (* Fill in the Item list. *) firstRow := LAddRow(numItems,0,ItemList); (* Insert rows *) FOR count := 1 TO numItems DO begin name := tempStringList^^.stringData; (* get item Name *) tempStringList := tempStringList^^.next; SetPt(theCell, 0, count - 1); (* select the proper cell *) LSetCell(POINTER(ORD(@name)+1),length(name),theCell,itemList); (* fill it *) end; LDoDraw(true,itemList) end; (* CreateList *) function listFilter( theDialog : DialogPtr; var theEvent : EventRecord; var item : integer): boolean; { modified code from Modal.pas by Scott Knaster; distributed with Turbo } const crCode = 13; enterCode = 3; var thetype : integer; finalTicks : longInt; theOkHdl : handle; begin listFilter := false; case theEvent.what of mouseDown : begin globalToLocal(theEvent.where); if PtInRect(theEvent.where,textRect) then selectedItem := doMouseClick(theEvent,theDialog, textRect,itemList); localToGlobal(theEvent.where) end; keyDown, autoKey : if (theEvent.message mod 256) in [crCode, enterCode] then {user pressed Return or Enter} begin GetDItem(theDialog,OK,theType,theOkHdl,textRect); HiliteControl(ControlHandle(theOkHdl),OK); Delay(3,finalTicks); listFilter := true; item := OK {simulate user hitting OK} end otherwise {do nothing} end {case theEvent.what} end; {function listFilter}