Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!silver!tsui From: tsui@silver.bacs.indiana.edu (Yufeng Tsui) Newsgroups: comp.sys.next Subject: Re: need advice on scrolling text fields Message-ID: <24909@iuvax.cs.indiana.edu> Date: 23 Aug 89 17:36:20 GMT References: <2240@hub.UUCP> Reply-To: tsui@silver.bacs.indiana.edu (Yufeng Tsui) Distribution: usa Organization: Indiana University, Bloomington Lines: 92 In article <2240@hub.UUCP> dz@cornu.ucsb.edu (Daniel James Zerkle) writes: >This is a shameless request for advice. > >As some of you may know, I am working on a project that will behave >similarly to the Digital Librarian. As such, I would like to use a >feature similar to the DL, both because it will be less confusing to >have a similar interface, and because it is a nice idea. > >I want to have a scrolling text field that will display file names, >one per line, very much like the file names are displayed by DL after >a search. When the user clicks on one of these lines, I want it to >be highlighted and for the program to tell which line was hit. I need >to be able to clear the whole field, also. > I just did that. I think what you need is a scrollView whose contentView is a matrix.(use buttonCell maybe? That way you can also use icons for the cell) Then you set the target for this matrix so that it send the message to the target when it is hit. Here is a piece of code from my program. It records user's commands and put them in the history window. The user then can run the command just by clicking... The code has not been cleard up yet, but it runs. - setUpHistoryWindow { NXRect aRect; id theScrollView,windowText; NXSize cSize; NXSetRect(&aRect,400,400,500,300); historyWindow = [Window newContent:&aRect style:NX_TITLEDSTYLE backing:NX_BUFFERED buttonMask:NX_ALLBUTTONS defer:NO]; [historyWindow setTitle:"history"]; [historyWindow setFreeWhenClosed:NO]; [historyWindow setBackgroundGray:NX_LTGRAY]; NXSetRect(&aRect, 0.0, 0.0,cSize.width,cSize.height); theScrollView = [ScrollView newFrame:&aRect]; [theScrollView setHorizScrollerRequired:YES]; [theScrollView setVertScrollerRequired:YES]; [theScrollView setBorderType:NX_BEZEL]; [theScrollView setAutoresizeSubviews:YES]; [theScrollView setDynamicScrolling:YES]; windowText = [Matrix newFrame:&aRect mode:NX_RADIOMODE cellClass:SelectionCell // ButtonCell will be better numRows:0 numCols:0]; [windowText setTarget:self]; [windowText setDoubleAction:@selector(IamHit:)]; // double click [windowText setEnabled:YES]; [historyWindow setContentView:theScrollView]; [theScrollView setDocView:windowText]; [theScrollView setBackgroundGray:NX_WHITE]; [theScrollView setDisplayOnScroll:YES]; [windowText sizeToFit]; return self; } - IamHit:sender { // get the sender's stringValue and pass it to my shellCmdView ... [shellCmdView setStringValue:[[sender selectedCell] stringValue] at:0]; return self; } - run:sender // after run the command, put it in to the history window. { char *aStr,*totalStr; int aLength; id theCell,theMatrix; aStr = [shellCmdView stringValueAt:0]; if (empty(aStr)) return self; if (history) { theMatrix=[[historyWindow contentView] docView]; theCell = [SelectionCell newTextCell:aStr]; [theMatrix setPrototype:theCell]; [theMatrix addRow]; [theMatrix selectCellAt:[theMatrix cellCount]-1:0]; [theMatrix sizeToCells]; [theMatrix sizeToFit]; [theMatrix display]; } [self clear:self]; [myMainWindow makeFirstResponder:shellCmdView]; return self; }