Application Developer Guide > Using Wave Widgets > Setting and Getting Widget Values
  

Setting and Getting Widget Values
Most of the widgets have values associated with them that are set when the widget is created.
After a widget is created, these values can be changed or obtained using the WwGetValue or WwSetValue routines.
The values that are set or obtained with WwSetValue and WwGetValue differ from one Wave Widgets routine to another. Refer to the specific routine descriptions in Chapter 7 for details.
For example, when WwSetValue is passed a widget ID from a widget created with WwList, the value that is set is an array of strings to replace the current items in the list. If WwGetValue is passed the widget ID from a widget created with WwList, it returns a string array containing the selected items in the scrolling list.
The following callback uses WwGetValue to obtain the list of selected items from a scrolling list. Then, WwSetValue is used to replace the selected items with new strings. To run this example, enter the callback routine in a file and compile it with the .RUN command. Then enter the widget commands at the WAVE> prompt.
Callback Procedure
PRO ListCB, wid, data
print,'Item Selected'
; Obtain values of the selected items in the scrolling list.
value = WwGetValue(wid)
print, value
print,'Setting..'
; Set the value of the scrolling list widget whose ID is wid to 
; the strings First, Second, and Third.
status=WwSetValue(wid, ['First','Second', 'Third'])
END
Widget Commands
top=WwInit('ww_ex18', 'Examples', layout)
; Define the list of items.
items = ['Presidents Day', 'St.Patricks Day',$ 
'Easter', 'Memorial Day', '4th of July',$
'Labor Day', 'Halloween', 'Thanksgiving',$
'Hanukkah', 'Christmas', 'New Years Eve']
; Create scrolling list widget displaying list of holidays. 
list=WwList(layout, items, 'ListCB',$ 
'DefaultCB', Visible=7,/Multi, Left=rbox, Top=controls)
status=WwSetValue(top, /Display)
WwLoop

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.