Re: WWTEXT scroll position. [message #18172 is a reply to message #18088] |
Wed, 01 December 1999 00:00  |
Mark D. Williams
Messages: 15 Registered: November 1999
|
Junior Member |
|
|
nittler@lepvax.gsfc.nasa.gov wrote:
> For one WAVE application, I want to use a widget text
> (WWTEXT) window to output information messages as the program runs,
> basically a console window. I have run into two problems. First there
> doesn't seem to be a way to directly append text to a WWTEXT widget.
> Well I fixed this by writing a routine to read the current contents of
> the widget, tack on the new contents and put the whole thing back in the
> widget. This is fine, but it leads to the second problem, namely that I
> can't figure out how to set the scroll position of the window. So, once
> I rewrite the text to the widget the scroll is always set to the first
> line, whereas I want it to be set to the most recently written (last)
> line. Can anybody help?
>
Try the following. It's a handy tip (that I have used before)
from VNI's on-line tips database:
The example code shows how to calculate the character offset
corresponding to
the desired row of the text and then set the appropriate resource for
the widget.
EXAMPLE CODE/FILES
pro ButCB, wid, data
common w, top, txt, txtsel, text
row = FIX(WwGetValue(txtsel)) ; Which row do we want?
eol = [0, WHERE(BYTE(text) EQ 10B)] ; Array of linefeed indicies
; (with 0 added for the first
line)
maxrow = n_elements(eol)-1 ; Max row of the data
offset = eol(row < maxrow) + 1 ; Position to use for topCharacter
args = {, topCharacter:offset} ; Set resource
status = WtSet(txt, args)
end
pro textpos
common w, top, txt, txtsel, text
top = WwInit('test','Test',layout,Backgr='cyan',/vertical)
label = ['Select this row:']
bbox = WwButtonBox(layout, label, 'ButCB')
txtsel = WwText(layout, Text='5')
text = 'Line 0 This is a test of positioning a text widget \012' + $
'Line 1 This is a test of positioning a text widget \012' + $
'Line 2 This is a test of positioning a text widget \012' + $
'Line 3 This is a test of positioning a text widget \012' + $
'Line 4 This is a test of positioning a text widget \012' + $
'Line 5 This is a test of positioning a text widget \012' + $
'Line 6 This is a test of positioning a text widget \012' + $
'Line 7 This is a test of positioning a text widget \012' + $
'Line 8 This is a test of positioning a text widget \012' + $
'Line 9 This is a test of positioning a text widget \012' + $
'Line 10 This is a test of positioning a text widget '
txt = WwText(layout, Text=text, /Read, cols=40, rows=10)
status = WwSetValue(top,/Display)
WwLoop, /Noblock
end
Regards,
Mark Williams
Resource Engineering, Inc.
|
|
|