You'll want to check out all of the WIDGET_* functions, and also take a look at this document:
http://www.exelisvis.com/...vent_Processing.html
Basically, you'll need to write an IDL widget program, and an event handler to process events from the widget. Start with something like the following code. And then type "example_widget" at the IDL command line to test it out:
pro example_widget_event, event
compile_opt idl2
Widget_Control, event.top, GET_UVALUE=pState
uName = Widget_Info(event.id, /UNAME)
case (uName) of
'Save': begin
openw, lun, 'testfile.txt', /GET_LUN, /APPEND
Widget_control, (*pState).wText, GET_VALUE=text
printf, lun, text
close, lun
free_lun, lun
end
else: begin
end
endcase
end ;example_widget_event, event
pro example_widget
compile_opt idl2
wBase = Widget_Base(/COLUMN)
wText = Widget_Text(wBase, /EDITABLE)
wButton = Widget_Button(wBase, VALUE='Save', UNAME='Save')
pState = Ptr_New({ $
wBase:wBase, $
wText:wText, $
wButton:wButton $
})
Widget_Control, wBase, SET_UVALUE=pState
Widget_Control, wBase, /REALIZE
XMANAGER, 'example_widget', wBase
end ;example_widget