comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: WIDGET_COMBOBOX
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: WIDGET_COMBOBOX [message #39290 is a reply to message #39289] Thu, 06 May 2004 19:23 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
PJL writes:

> Does anyone know a way that the text portion of the WIDGET_COMBOBOX
> can be manually updated? The IDL help does not document as such, all
> there seems to be is COMBOX_ADDITEM which adds the item to the list.
> But surely there must be some way to edit just the text box from
> within the program since the user can manually type something in if
> the EDITABLE keyword is set.

I'm not sure it is always straightforward to know what to
do with the value of the combobox. If you are trying to set
the value to a value in the list, it is easy. But if you
are trying to set the value to something *not* on the list,
what do you do?

Here is one way to solve the problem:

;*****************************************************
PRO test_event, event

box = Widget_Info(event.top, /Child)
Widget_Control, box, get_value=values

name = Tag_Names(event, /Structure_Name)
IF name NE 'WIDGET_BUTTON' THEN RETURN

Widget_Control, event.id, Get_Value=buttonValue
CASE buttonValue OF

'Set It to Moe': BEGIN
index = Where(values EQ 'Moe')
IF index GT 0 THEN Widget_Control, box, Set_ComboBox_Select=index
END

'Set It to Fred': BEGIN

; Is the current value Fred?
name = Widget_Info(box, ComboBox_GetText=1)
index = Where(StrUpCase(values) EQ StrUpCase(name), count)
IF count GT 0 THEN BEGIN
I = Where(StrUpCase(values) EQ 'FRED', count)
IF count GT 0 THEN BEGIN
Widget_Control, box, Set_ComboBox_Select=I
ENDIF ELSE BEGIN
values[index] = 'Fred'
Widget_Control, box, Set_Value=values
Widget_Control, box, Set_ComboBox_Select=index
ENDELSE
ENDIF ELSE BEGIN
values = [values, 'Fred']
Widget_Control, box, Set_Value=values
Widget_Control, box, Set_ComboBox_Select=N_Elements(values)-1
ENDELSE

END

ENDCASE

END


PRO Test

tlb = Widget_Base(Column=1)
box_values = ['Larry', 'Moe', 'Curley']
box = Widget_Combobox(tlb, value=box_values, /Editable)
button = Widget_Button(tlb, Value='Set It to Moe')
button = Widget_Button(tlb, Value='Set It to Fred')
Widget_Control, tlb, /Realize, Set_UValue=box_values
XManager, 'test', tlb, /No_Block

END
;*****************************************************


Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: XML parser question: How to use a schema?
Next Topic: Re: Assigning NaN to arrays

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:04:24 PDT 2025

Total time taken to generate the page: 0.00515 seconds