Generic event handlers...

Artic_Ice83

18-12-2007 13:34:34

Hi! i'm sorry for the enormous quantity of questions, but i'm a noob...
well, i'd like to know if there is a manner to make a generic event handler. for example, can i make a generic mouse event handler? than, if i pass to the handler the event and control the type of mouse event i can call a specific function...

kungfoomasta

18-12-2007 17:06:50


void myClass::buttonClicked(const EventArgs& args);

button1->addEventHandler(EVENT_MOUSE_BUTTON_DOWN,&myClass::buttonClicked,myClassObject);
button2->addEventHandler(EVENT_MOUSE_BUTTON_DOWN,&myClass::buttonClicked,myClassObject);
button3->addEventHandler(EVENT_MOUSE_BUTTON_DOWN,&myClass::buttonClicked,myClassObject);


Is this what you mean?

Artic_Ice83

18-12-2007 19:07:48

maybe a thing like this:



button1->addEventHandler(EVENT_MOUSE_BUTTON,&myClass::buttonClicked,myClassObject);

void myClass::buttonClicked(const EventArgs& args)
{
if(event == EVENT_MOUSE_BUTTON_DOWN)
// do something
else
// do other
}

kungfoomasta

18-12-2007 19:27:20

Interesting! I will work on this, should be a quick add, and could prove valuable down the road.


Widget::addEventListener(....);

void yourFunction(QuickGUI::Widget::Event e, const EventArgs& args);


Will add this in sometime in next few days.

Artic_Ice83

18-12-2007 21:13:43

Yeah! i think that this functionality could be useful because permits to handle different type of events from one or more widgets!

kungfoomasta

24-12-2007 01:03:52

Implemented in SVN.

EventArgs also give the type of event that was fired.

Artic_Ice83

24-12-2007 20:22:21

well!! thanks for the implementation!
i will update my code!!! :D