A SERVICE OF

logo

308 Chapter 13: Creating a User Interface Service
Example: Changing a Property Value iTool Developer’s Guide
Discussion
It is beyond the scope of this chapter to discuss the IDL widget programming
techniques used in this example. For more information on widget programming, see
the Building IDL Applications manual. Several points are worth noting, however.
The widget ID of the top-level base retrieved in the SrvExample routine is
passed to this routine, and used as the value of the GROUP_LEADER
keyword to WIDGET_BASE. This ensures that if the iTool itself is minimized
or closed while the example dialog is displayed, it will be handled properly.
The original value of the NAME property is passed to this routine, and is
stored in an IDL pointer variable within the state structure that is associated
with the dialog. This allows the event routine that actually retrieves the value
entered by the user to communicate the new value back to the widget creation
routine, but it also means that the pointer must be freed before the routine exits.
Event-handling Routines
The following event-handling procedures handle widget events generated by the
widget interface that is displayed when the SrvExample user interface service is
called.
PRO wdSrvExample_ok, event
; Get the stashed state structure from the user value
; of the top-level base widget.
WIDGET_CONTROL, event.top, GET_UVALUE = state
; Get the value from the editable text field.
WIDGET_CONTROL, state.wEdit, GET_VALUE = value
; Store the text value in a pointer so we can access
; it from the main routine
*state.pName = value
; Destroy the dialog.
WIDGET_CONTROL, event.top, /DESTROY
END
PRO wdSrvExample_cancel, event
; Nothing to do, just destroy the dialog.
WIDGET_CONTROL, event.top, /DESTROY
END