rezaali / ofxUI

[DEPRECATED] UI Addon for openFrameworks
http://www.syedrezaali.com/#/ofxui-project-showcase/
518 stars 202 forks source link

How do you get a GUI event's type? #219

Closed K0j0 closed 9 years ago

K0j0 commented 10 years ago

Hey there.

So I'm using an ofxUIButton with the same event listener setup from the examples ofAddListener(gui->newGUIEvent,this,&SomeClass::guiEventHandler) and noticed that it fires an event both when it's pressed and when it's released. Now in the gui event handler, the ofxUIEventArgs parameter doesn't give any information about the kind of event that's fired. After a little poking around I noticed that the "state" property of ofxUIWidget has pretty much the information I'm looking for. I was surprised to see that there was no getState() method on ofxUIWidget or ofxUIButton though. Is there some other way I'm supposed to know whether the event was a press or release?

For now I'm just going to add a getState() method but I wonder if I'm missing something else. Please let me know. Thanks!

arminbw commented 9 years ago

I'm using getValue(). Works like a charm.

K0j0 commented 9 years ago

I'm not really sure what you mean. I was looking for the event type (mouse down, mouse up). The function getValue() is defined differently for different widgets and none of them return the event type. The getState() function I added has worked just fine though. Please explain if I'm missing something obvious though.

K0j0 commented 9 years ago

Ok, I see what you mean. getValue() does work for ofxUIButton.