ftp.nice.ch/peanuts/GeneralData/Usenet/news/1989/CSN-89.tar.gz#/comp-sys-next/1989/Jan-Apr/writing-to-a-ScrollView

This is writing-to-a-ScrollView in view mode; [Up]


Date: Sun 06-Mar-1989 09:29:18 From: Unknown Subject: writing to a ScrollView Has anyone had any luck in writing a string out to a scrollable window? I've been trying for about a week to get a large string out to a scrollable window and I haven't gotten more then 1 line to appear. The following is what I'm currently doing... extern char *help; // This is the string I want to write (defined as: char *help = "This is a really long string that" "I want to print out in a scrolling window\n";) //... //... [[helpText docView] setText:help]; [[helpText window] orderFront:self]; [[NXApp runModalFor:[helpText window]]; [[helpText window] orderOut:self]; This will get the first line of my string out to the scrollView. Unfortunatly, It clips at the end of the docView and I haven't been able to get it to wrap around the view. I've also tried to setCharWrap:YES but that didn't seem to help the clipping problem. There's some stuff mentioned in ScrollView.dl, but it redefines the word terse :-) As one attempt to wrapping, I tried to put in newlines at the end of every few words, then the setText just printed the string out until it came to the first newline. Has anyone figured this problem out yet? Tom leach leach@oce.orst.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Middle-of-the-road, man, it stanks. Let's run over Lionel Richie with a tank. >>>Disclaim: It's me, not OCE.<<< B. Catt, Deathtongue. (c 1986) >From: mrc@Tomobiki-Cho.acs.washington.edu (Mark Crispin)
Date: Sun 06-Mar-1989 19:42:02 From: Unknown Subject: Re: writing to a ScrollView Here's the method I have to do what you want. It isn't very pretty, but it does the job. I'd be happy to get any word on a better way to do this. As a general comment, sometimes there is *too much* documentation on the NeXT, and simple answers to simple questions get obscured. telemetryView is an instance variable that is set by an outlet connected to the Scrolling TextView inside my window. The scrolling is a bit strange. By default, the contentView will stay at the top of the docView. What I did was take the docView's rectangle and set its origin to its height. This creates a rectangle that is immediately below the docView; I then scroll to make that rectangle visible. It can't, of course, but it scrolls as close as it can (to the bottom). The other strange thing about the scrolling is that it scrolls before the text is output. That's because, in the application it lives, that there's a [mumble telemetry:"\n"]; method call after any strings it outputs. So, the scrolling goes before so it doesn't scroll to a blank line. A more reasonable thing may be to scroll at the end, and make the callers output the \n before a new string instead of after. I wanted line breaking at the end of the physical line, ignoring word boundaries. If breaking at the nearest convenient word boundary is what you want, remove the invocations to setNoWrap and setCharWrap:. I used replaceSel: as an "append string to text" method, taking advantage of the fact that no text can be selected in this window so by default it'll just dump where the cursor is...at the end. /* Send a string to the telemetry window * Accepts: string * * This is not a very pretty function. I hope someone can tell me a better * way to do do this. */ - telemetry:(char *)string { NXRect rect; /* get the current bounds of this view */ [telemetryView getBounds:&rect]; /* make a rectangle of the bottommost line */ rect.origin.y = rect.size.height; /* make sure that line can be seen */ [telemetryView scrollRectToVisible:&rect]; [telemetryView setNoWrap]; /* kill all wrapping */ /* wrap by characters */ [telemetryView setCharWrap:YES]; /* blat the string */ [telemetryView replaceSel:string]; return self; } -------- Mark Crispin / P.O. Box 2652 / Seattle, WA 98111-2652 / (206) 842-2385 mrc@Tomobiki-Cho.CAC.Washington.EDU / MRC@WSMR-SIMTEL20.Army.Mil 250cc Rebel pilot -- I just wind it up and it goes! kisha no kisha ga kisha de kisha-shita...tabesaserarenakerebanaranakattarashii >From: UH2@PSUVM.BITNET (Lee Sailer)

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.