Custom tgui::Signal functions

Started by Xdesign, 27 February 2022, 20:21:53

Xdesign

Hello!
Im wondering how can i create custom functions like onSizeChange()?
Im trying to create something like Task::onStateChange().
In my Group class i have array of tasks.
Group::pushTask(){
     tasks.push_back(Task::create());
     tasks.[tasks.size-1]->onStateChange(&Group::TaskStateChanged,this,tasks.size()-1);
}
Group::TaskStateChanged(int index){
     tasks[index]->....
     ...
}
So when task changes state in scope Group::TaskStateChanged will be called.

Thanks!


texus

You can find some information about custom signals at https://tgui.eu/tutorials/0.10/custom-widgets/#adding-signals

Your Task class would have a "tgui::Signal onStateChange = {"StateChanged"};" member and TaskStateChanged would call "tasks[index]->onStateChange.emit(this);".

Xdesign

Oh sorry i missed that.
Thank you!