WgText Procedure
Displays a single-line text field for user input.
Usage
WgText, chars
Input Parameters
chars — A named or unnamed variable to be replaced with user input.
Output Parameters
chars — A string entered by the user. If WgText is dismissed before user input is entered, chars is set to a null string. In the case where a user enters numbers, chars will have to be type-cast. For example, if chars = '123.456', then FLOAT(chars) = 123.456.
 
note
wgtext_output — A common block internal to WgText containing one variable, which is the text entered by the user. When WgText is called stand-alone, it runs in its own event loop. Once the user finishes typing their input, control is passed back to the calling routine and the user input is accessed through the variable chars. However, if WgText is called from an existing widget application, the tool must use this calling widget's event loop. In this case, WgText is executed and control is passed back immediately to the calling widget application, before the user can enter their string into the text field. To allow the widget application that calls WgText to have access to the most recent entry by the user, include this common block in the calling widget application.
Keywords
Cols — An integer specifying the character width of the text field.
Parent — The widget ID of the parent widget. If no parent is specified, the toolkit is initialized and WgText runs in its own event loop.
Position — A two element vector containing the position, in pixels, of WgText's upper-left corner where [0,0] is the upper-left corner of the display.
Text — A string to be initially displayed in the text field. If not defined, the text field is empty.
Title — A string containing the title for the widget.
Shell — (Output) The ID of the newly created widget. If the procedure fails, zero (0) is returned.
Background — The background color (passed to all widgets).
Font — The font to use for widget text.
Foreground — The foreground color (passed to all widgets).
Example 1
WgText called from the command line.
; Font choice syntax different for Windows or UNIX...
IF STRMATCH(GETPLATFORM(), 'win') THEN fnt = 'Forte, 10' $
   ELSE fnt='-adobe-*-bold-*-*-*'
WgText, myString, Position=[300,100], Text='Default string', $
   Shell=shell, Background='Green', Font=fnt
INFO, myString, shell
Example 2
WgText called from another widget application.
PRO BUTTONSCB, wid, which
   COMMON teststuff, workArea
   COMMON wgtext_output, letters
     CASE which OF
       1: WgText, junk, Parent=workArea, Text='Have a nice day',$
          Title='Hello', Fore='Red', Pos=[100,600], Shell=shell
       2: BEGIN
          IF N_ELEMENTS(letters) GT 0 THEN BEGIN
            PM, letters, Title="You entered:"
          ENDIF ELSE BEGIN
            PRINT, STRING(7B)
            PRINT, 'Nothing has been entered yet'
          ENDELSE
          END
       ENDCASE
END
 
PRO WGTEXT_TEST
   COMMON teststuff, workArea
   topShell = WwInit('WgText_test','WgText_test', workArea, $
      /Vertical, Position=[256,256], Spacing=5, Height=100, $
      Width=350)
   buttons = WwButtonBox(workArea, ['Call wgtext', $
      'See result'], 'BUTTONSCB')
   status=WwSetValue(topShell, /Display)
   WwLoop
END