rdd@walt.cc.utexas.edu (Robert Dorsett) (12/11/89)
I'm attempting to use the List Manager, from within a dialog, to implement a one-column list of text cells. The length of the list can vary, with items being deleted and added at any point within the list. My problem is that I'm unable to get the cell ID of the currently-selected item. I'm convinced I'm adding data to the list correctly list correctly (dataBounds for the list looks okay), but if I try LLast to get the point, it doesn't work. If, on the other hand, I use LGetSelect, the numbers are too high (but not by much, which raises the maddening question of whether I'm installing the data correctly). I also need to know, ABSOLUTELY, whether an item is selected or not. This is my first tangle with the List Manager. If anyone has any suggestions or advice (or code! :-)), I'd appreciate hearing them. I need to get this problem solved ASAP, but am starting to think it'd be easier to write my own List Manager from scratch. Robert Dorsett Internet: rdd@rascal.ics.utexas.edu UUCP: ...cs.utexas.edu!rascal.ics.utexas.edu!rdd
jackiw@cs.swarthmore.edu (Nick Jackiw) (12/12/89)
rdd@walt.cc.utexas.edu (Robert Dorsett) writes: > I'm attempting to use the List Manager, from within a dialog, to implement a > one-column list of text cells. The length of the list can vary, with items > My problem is that I'm unable to get the cell ID of the currently-selected > item. I'm convinced I'm adding data to the list correctly list correctly > (dataBounds for the list looks okay), but if I try LLast to get the point, it > doesn't work. If, on the other hand, I use LGetSelect, the numbers are too > high (but not by much, which raises the maddening question of whether I'm > installing the data correctly). > > Robert Dorsett > Internet: rdd@rascal.ics.utexas.edu > UUCP: ...cs.utexas.edu!rascal.ics.utexas.edu!rdd I assume from your post that your list permits only one item to be selected at a time. Good. begin {Modal List Dialog} theDLOG:=GetNewDialog(theDLOG_Id,nil,pointer(-1)); InstallUserItem(theDLOG,List_ITEM,@DrawList); SetPort(theDLOG); {At this point, it's assumed the list already exists; you've done LNew} theList^^.SelFlags:=lOnlyOne; ShowWindow(theDLOG); LDoDraw(true,theList); repeat ModalDialog(@ModalProc,itemHit); if itemHit=List_Item then {Translate double-clicks into Opens} if LClick(GlobalPt,0,theList) then itemHit:=Open_ITEM; until (itemHit=Open_ITEM) or (itemHit=Cancel_ITEM); if itemHit=open_ITEM then begin {Figure out which item is selected; that's what we want to open} SetPt(aPt,0,0); junk:=LGetSelect(true,aPt,theList); aStr:='#####################'; oldLen:=length(aStr); LGetCell(ptr(longint(@aStr)+1),oldLen,aPt,theList); {aStr now contains the text of your item to be opened; act appropriately} ... end; end; ---------------------- This scheme uses a global variable, globalPt, to record the coordinates of the last mousedown (that's the purpose of modalProc), so that our main loop, above, can send that point to the list manager for double- clicks. (Alternately, doubleClicks could be detected in the filterProc, which would obviate the need for a global.) ----- If this doesn't help, why don't you post your code? -- _ _|\____ Nick Jackiw | Visual Geometry Project | Math Department / /_/ O> \ ------------+-------------------------+ Swarthmore College | O> | 215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081 \_Guernica_/ ------------+-------------------------+ USA