combobox widget text [message #63577] |
Fri, 14 November 2008 14:17  |
greg.addr
Messages: 160 Registered: May 2007
|
Senior Member |
|
|
Does anyone know how to set the value of an editable combobox such
that it's *not* one of the current list items? I have the drop-down
filled with standard values, but want to be able to save and recover a
user entered value
cheers,
Greg
.
|
|
|
|
Re: combobox widget text [message #63664 is a reply to message #63577] |
Sat, 15 November 2008 08:31  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Widget_Control, event.id, 4
> SET_COMBOBOX_SELECT=N_Elements(newList)-1
Whoops! That "4" should be a dollar sign ($).
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: combobox widget text [message #63665 is a reply to message #63577] |
Sat, 15 November 2008 08:30  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
greg michael writes:
> Thanks, David, for that very nice example. Maybe it's a strange thing
> to wish for, but I was hoping to put a value into the edit box without
> changing the drop-down list. My application is this: I want to display
> an image at a selected resolution - normally a multiple of the true
> resolution (12.5 m/pix, 25, 50, 100...) - but to allow the possibility
> to enter any value in between. Hence the combobox. I also want to be
> able to save and recover the view, so I need to put a value back into
> wherever ev.str comes from. I'd expect to find it as a
> widget_control,set_something= but I don't see it. Any ideas?
Oh, alright. How about this:
PRO ComboWidgetTest_Event, event
Widget_Control, event.id, GET_UVALUE=defaultList
IF event.index EQ -1 THEN BEGIN
I = Where(StrUpCase(defaultList) EQ StrUpCase(event.str), count)
IF count EQ 0 THEN BEGIN
newList = [defaultList, event.str]
Widget_Control, event.id, SET_VALUE=newList
Widget_Control, event.id, 4
SET_COMBOBOX_SELECT=N_Elements(newList)-1
ENDIF
ENDIF ELSE BEGIN
IF event.index EQ N_Elements(defaultList) THEN RETURN
Widget_Control, event.id, SET_VALUE=defaultList
Widget_Control, event.id, SET_COMBOBOX_SELECT=event.index
ENDELSE
END
;----------------------------------------------------------- ------------
PRO ComboWidgetTest, newValue
IF N_Elements(newValue) EQ 0 THEN newValue = 'pig'
tlb = Widget_Base(/COLUMN, XOFFSET=150, YOFFSET=150)
defaultValues = ['dog', 'cow', 'coyote']
combo = Widget_Combobox(tlb, VALUE=[defaultValues, newValue], $
/EDIT, SCR_XSIZE=100, UVALUE=defaultValues)
Widget_Control, tlb, /REALIZE
Widget_Control, combo, Set_Combobox_Select = 3
XManager, 'combowidgettest', tlb, /NO_BLOCK
END
;----------------------------------------------------------- ------------
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|