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. |
; 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
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