; $Id: w_simpleedit.pro,v 1.0 1997/05/23 mgs $ ;+ ; NAME: ; w_simpleedit ; PURPOSE: ; creates a simpleedit dialog that allows to choose simpleedit simpleedit ; ; CATEGORY: ; Modal widgets. ; ; CALLING SEQUENCE: ; widget = w_simpleedit(parent) ; ; INPUTS: ; PARENT - The ID of the parent widget. ; ; KEYWORD PARAMETERS: ; UVALUE - Supplies the user value for the widget. ; ; OUTPUTS: ; The ID of the created widget is returned. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; ; PROCEDURE: ; ; MODIFICATION HISTORY: ;- ;----------------------------------------------------------------------------- FUNCTION simpleedit_event, event parent=event.handler ; the event usually must be passed further up ! ; and the next higher event handler must destroy the window ; (cannot be destroyed here, because we need the info !) passevent = 0 ; Retrieve the structure from the child that contains the sub ids. stash = WIDGET_INFO(parent, /CHILD) WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY if(event.id eq state.bID) then begin ; button pressed (OK or Cancel) if(event.value eq 0) then begin ; OK widget_control,state.fid,get_value=info endif value = 1-event.value ; OK=1, (Cancel=0) passevent = 1 endif ; Restore the state structure WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY if(passevent) then $ return, { ID:parent, TOP:event.top, HANDLER:0L, VALUE:value , $ INFO:info } $ else return,0 END ;----------------------------------------------------------------------------- FUNCTION w_simpleedit, TITLE=title, PROMPT=prompt, UVALUE=uval, VALUE=value ; value contains initial string ON_ERROR, 2 ;return to caller ; Defaults for keywords IF (n_elements(uval) eq 0) THEN uval = 0 if (n_elements(value) eq 0) then value = '' if (n_elements(prompt) eq 0) then prompt = 'Edit:' if (n_elements(title) eq 0) then title = ' EDIT ' base = WIDGET_BASE(TITLE=title, UVALUE = uval, $ /column, EVENT_FUNC = "simpleedit_event" ) field = cw_field(base,value=value,title=prompt) buttons = cw_bgroup(base,/row,[' OK ','Cancel']) state = { bID:buttons, fid:field } ; Save out the initial state structure into the first childs UVALUE. WIDGET_CONTROL, WIDGET_INFO(base, /CHILD), SET_UVALUE=state, /NO_COPY RETURN, base END