Jump to content

[SOLVED] Callback with parameters of more than one


photo

Recommended Posts

Posted

Hi.

 

How do I file a interfeys.ui the call callback to set more than one parameter?
Example:
// inventory.ui
<button>
   <text>Buy</text>
   <callback type="clicked" string="abc" string="50">Game::buy</callback>
</button>
// game.h
void buy (string name, string cost) {
   //
}

 

Thank.

 

Posted

A workaround:

 

<callback type="clicked" string="abc,50">Game::buy</callback>

 

 

void buy(string data) {
  string args[0];
  strsplit(data,",",args);
  //args[0] == "abs"
  //args[1] == "50"
}

 

Posted
Thank you.

 

And one more question. I can dynamically change these variables? for example: string="abc,50" => string="abc,30"
Posted

You have to reinite the callback for this widget:

 

widget.setCallback(GUI_CLICKED,"buy","abc,30");

 

×
×
  • Create New...