mygui events on overloaded functions

mrmclovin

31-12-2008 01:56:47

Im tryin to set diffrent widgets events to the same gui listener. For instance, a Button and one of the List event requires an extra param.
void onGuiEvent(MyGUI::WidgetPtr); // for buttons and other widgets
void onGuiEvent(MyGUI::WidgetPtr, size_t index); // for a special list event

Register callbacks:
mDelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &LevelEditor::onGuiEvent(MyGUI::WidgetPtr));
mList->eventListSelectAccept = MyGUI::newDelegate(this, &LevelEditor::onGuiEvent(MyGUI::WidgetPtr, size_t));

But I get a bunch of errors.

Is it possible in MyGUI/C++ ?

if not, any tips on what I can do to keep all events linked to one function?

my.name

31-12-2008 09:40:21


void onGuiEventButton(MyGUI::WidgetPtr); // for buttons and other widgets
void onGuiEventList(MyGUI::WidgetPtr, size_t index); // for a special list event

mDelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &LevelEditor::onGuiEventButton);
mList->eventListSelectAccept = MyGUI::newDelegate(this, &LevelEditor::onGuiEventList);

nikki

01-01-2009 21:37:36

Umm, you don't pass parameter types to a function address reference.

my.name

02-01-2009 08:53:28


struct A
{
void foo(MyGUI::WidgetPtr _sender) { }
void foo(MyGUI::WidgetPtr _sender, bool _focus) { }
};

A a;

void (A::*foo1)(MyGUI::WidgetPtr);
void (A::*foo2)(MyGUI::WidgetPtr, bool);

foo1 = &A::foo;
foo2 = &A::foo;

widget->eventMouseButtonDoubleClick = MyGUI::newDelegate(&a, foo1);
widget->eventRootMouseChangeFocus = MyGUI::newDelegate(&a, foo2);




struct A
{
void foo(MyGUI::WidgetPtr _sender) { }
void foo(MyGUI::WidgetPtr _sender, bool _focus) { }
};

A a;

typedef void (A::*foo1)(MyGUI::WidgetPtr);
typedef void (A::*foo2)(MyGUI::WidgetPtr, bool);

widget->eventMouseButtonDoubleClick = MyGUI::newDelegate(&a, (foo1)&A::foo);
widget->eventRootMouseChangeFocus = MyGUI::newDelegate(&a, (foo2)&A::foo);