dmitriy.ogorodnikov Posted October 3, 2014 Share Posted October 3, 2014 Class Widget has function to set callback: WIDGET::setCallback (int callback, variable function, variable data_0,variable data_1, variable data_2, variable data_3) This function can have up to 4 function parameters (data_0, data_1, data_2, data_3). We can also set callback function name at ui-file Source code (XML) <callback type="clicked">Window::close_window</callback> Can we set parameters for callback function at XML ? Link to comment
silent Posted October 3, 2014 Share Posted October 3, 2014 Hi Dmitry, Yes, you can easily set your custom parameters. For example: <callback type="clicked" string="Hello">Window::close_window</callback> void close_window(string FromXml) { log.message(FromXml); } All available parameters you can find here: https://developer.unigine.com/en/docs/1.0/code/gui/ui_widgets Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
dmitriy.ogorodnikov Posted October 3, 2014 Author Share Posted October 3, 2014 Hi Dmitry, Yes, you can easily set your custom parameters. For example: <callback type="clicked" string="Hello">Window::close_window</callback> void close_window(string FromXml) { log.message(FromXml); } All available parameters you can find here: https://developer.unigine.com/en/docs/1.0/code/gui/ui_widgets Thanks! For string it works. I would like to pass int parameter through XML. I tried to use variable parameter, but didn't get success. What should I do ? Link to comment
silent Posted October 3, 2014 Share Posted October 3, 2014 You can easily convert your string parameter to int, for example: int(FromXml). How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
dmitriy.ogorodnikov Posted October 3, 2014 Author Share Posted October 3, 2014 Ok, thank you, it works. How to use variable parameter, I didn't understand from Docs. There isn't clear for me too. Where is declared this variable: in xml or in UnigineScript ? How to use it ? Link to comment
silent Posted October 3, 2014 Share Posted October 3, 2014 You can pass variable by it's name, like this: //cpp int variable = 100500; void callback(int var) { log.message("var: %d",var); } //ui <checkbox align="expand"> <callback type="clicked" variable="variable">callback</callback> <text>CheckBox</text> </checkbox> Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
dmitriy.ogorodnikov Posted October 3, 2014 Author Share Posted October 3, 2014 Thank you very much, there are no questions. Link to comment
Recommended Posts