PDA

View Full Version : Passing Variables to Callback Functions



raoxx083
01-06-2010, 10:57 AM
Is there a way to pass variables to GUI callback functions? We currently use common blocks to define variables within the callbacks but I was hoping there was a better way of doing it.

Thanks for the help.

rwagner
01-06-2010, 01:51 PM
No, common blocks are the best way to do this.

totallyunimodular
01-06-2010, 03:20 PM
Without knowing more about your specific problem, I'd suggest taking a look at the Passing and Retrieving User Data section of the Application Developer's Guide (Chapter 5):

WAVE> HELP, /Document

brings up the manuals online...

Basically, you can use WwSetValue and WwGetValue with the Userdata keyword to associate data with a given widget. A callback function for that widget may then access data from expected input parameters, global variables (via COMMON blocks), or something like


PRO my_callback, wid, required_input_data
optional_data_I_want = WwGetValue(the_widget, /Userdata)
;Do some stuff...
END

where somewhere in the parent routine you would have something like


status = WwSetValue(the_widget, Userdata=some_data_structure)

Hope that helps