newDelegated is deprecated in MyGUI 3.2

siondream

16-06-2011 19:30:37

Hi there!

I just started using MyGUI 3.2 and realized that the docs [1] are really outdated. I've checked the renaming advices [2] but I still have problems. The tutorial tells you to use the MyGUI::newDelegate function to create event handlers like for widget events like this:



class StateMenu: public State {
public:
StateMenu(StateManager* stateManager);
~StateMenu();

void load();
void clear();

void update(Ogre::Real deltaT, bool active);

bool keyPressed(const OIS::KeyEvent &arg);
bool keyReleased(const OIS::KeyEvent &arg);
bool mouseMoved(const OIS::MouseEvent &arg);
bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);

void btnExitClicked(MyGUI::WidgetPtr sender);

private:
MyGUI::Gui* _myGUI;
MyGUI::ButtonPtr _btnExit;
};

void StateMenu::load() {
MyGUI::LayoutManager::getInstance().loadLayout("sample.layout");

_btnExit = _myGUI->findWidget<MyGUI::Button>("MyFirstButton");
_btnExit->eventMouseButtonClick = MyGUI::newDelegate(this, &StateMenu::btnExitClicked);
}

void StateMenu::btnExitClicked(MyGUI::WidgetPtr sender) {
_stateManager->exitGame();
}


But the compiler throws the following warning and the btnExitClicked method is never called:


src/stateMenu.cpp:38: warning: ‘MyGUI::delegates::CMultiDelegate1<TP1>& MyGUI::delegates::CMultiDelegate1<TP1>::operator=(MyGUI::delegates::IDelegate1<TP1>*) [with TP1 = MyGUI::Widget*]’ is deprecated (declared at /usr/local/include/MYGUI/MyGUI_DelegateImplement.h:340)



What should I do? Thank you very much.

[1] http://www.ogre3d.org/tikiwiki/MyGUI+quickstart
[2] viewtopic.php?f=17&t=13936&p=78484&hilit=deprecated#p78484

Altren

17-06-2011 00:48:43

That change was made in MyGUI 3.0.* (don't remember when exactly). Delegates replaced with multidelegates, so use operator += instead of operator =.
_btnExit->eventMouseButtonClick += MyGUI::newDelegate(this, &StateMenu::btnExitClicked);
And thanks for pointing this out - I fixed wiki page.

siondream

17-06-2011 09:00:48

That change was made in MyGUI 3.0.* (don't remember when exactly). Delegates replaced with multidelegates, so use operator += instead of operator =.
_btnExit->eventMouseButtonClick += MyGUI::newDelegate(this, &StateMenu::btnExitClicked);
And thanks for pointing this out - I fixed wiki page.


Thank you very much, that solved the warning! :-)