Application Developer Guide > Using Wave Widgets > Creating a Text Widget
  

Creating a Text Widget
The WwText function can be used to create three kinds of text widgets:
*A single-line read-only label.
*A single-line editable text field, used for user input.
*A multi-line text window that can be read-only or editable.
Horizontal and vertical scroll bars allow the user to scroll through the multi-line text window.
Single-line Label (Read-only)
To create a single-line read-only text label, use the WwText function with the Label keyword. For an example, see Static Label and Editable Text Field Example in this section.
Single-line Editable Text Field
To create a single-line editable text field, use the WwText function. This text widget is used primarily for applications that require the user to enter a value or a string. WwText returns a string, which can be passed to the callback for processing.
Static Label and Editable Text Field Example
This example creates an editable text field with a label. The left edge of the text field widget is attached to the right edge of the label widget. The result is shown in Editable Text Field with Label.
; Initialize Wave Widgets and create the form layout widget.
top=WwInit('ww_ex11', 'Examples', layout, /Form)
; Create the label widget.
label=WwText(layout, /Label, Text='This is Label')
; Create the single-line text field widget, attaching it to the
; right edge of the label widget.
text=WwText(layout, 'TextCB', Cols=40, left=label)
status=WwSetValue(top, /Display)
WwLoop
 
Figure 5-20: Editable Text Field with Label
Multi-line Text Window
To create a multi-line text window, use the WwText function with the Col and Rows keywords to specify the height and width of the text area. If you use the Read keyword, the text area is read-only. If this keyword is not used, then the user can edit the text using the standard editing keys on the keyboard or the mouse (for example cut and paste).
Example
This example creates a multi-line, read-only text window 40 columns by 20 rows, and displays the text from the file air_qual.dat. The result is shown in Multiline Text Window.
top=WwInit('ww_ex12', 'Examples', layout)
filename = getenv('WAVE_DIR')+ '/data/air_qual.dat'
text=WwText(layout, 'TextCB', /Read, File=filename, Cols=40, $
Rows=20)
status=WwSetValue(top, /Display)
WwLoop
 
Figure 5-21: Multiline Text Window

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.