note | wgfileselection_output — A common block internal to WgFileSelection containing one variable, which is the file (and path) selected by the user. When WgFileSelection is called stand-alone, it runs in its own event loop. Once the user finishes choosing their file, control is passed back to the calling routine and the user's choice is accessed through the variable path. However, if WgFileSelection is called from an existing widget application, the tool must use this calling widget's event loop. In this case, WgFileSelection is executed and control is passed back immediately to the calling widget application, before the user can make their selection. To allow the widget application that calls WgFileSelection 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-*-*-*'
WgFileSelection, theFile, Pattern='*.txt', Back='Red', Font=fnt
PM, theFile
.RUN
PRO BUTTONSCB, wid, which
COMMON teststuff, workArea
COMMON wgfileselection_output, theFile
CASE which OF
1: WgFileSelection, junk, Parent=workArea, $
Pattern='*.pro', File='wgfs_test.pro', $
Title='Have a nice day', Back='darkgreen', $
Position=[100,600], Shell=shell
2: BEGIN
IF N_ELEMENTS(theFile) GT 0 THEN BEGIN
PM, theFile, Title="You chose the file:"
ENDIF ELSE BEGIN
PRINT, STRING(7B)
PRINT, 'Nothing has been selected yet'
ENDELSE
END
ENDCASE
END
COMMON teststuff, workArea
topShell = WwInit('WgFS_test','WgFS_test', workArea, $
/Vertical, Position=[256,256], Spacing=5, Height=100,$
Width=350)
buttons = WwButtonBox(workArea, ['Call wgfileselection', $
'See result'], 'BUTTONSCB')
status=WwSetValue(topShell, /Display)
WwLoop