[SOLVED] Events button in other class

Hi, Urhofans.

I have my Application class where I can check the events, but I would like make other class
and check new events there like buttons.

Can somebody help me? :unamused:

[color=#FF0000]Suscribetoevent was not declared in this scope[/color]

Hi,

You probably want to make your class a subclass of Object, which has the SubscribeToEvent method.

For example, the Character class from CharacterDemo subclasses LogicComponent, so it’s also an Object.
github.com/urho3d/Urho3D/tree/m … racterDemo

urho3d.github.io/documentation/H … types.html

HTH

Thank you very much!

:smiley:

Urho3D has a great community.

But… not work in my case :cry:

I only want create a

[color=#4040BF]SubscribeToEvent(button, E_RELEASED, URHO3D_HANDLER(MyNewClass, MyButtonFunction));[/color]

in the new class.

Ok. Now works, but I need set the new class as LogicComponent :stuck_out_tongue: I’m not sure if this is the best solution :unamused:

No, not work :question:

void MyNewClass::Press_Switch(StringHash eventType, VariantMap& eventData) { text_password->SetText("HELLO"); cout << "SWITCH WORKS!" << endl; }

When I press my switch button, the app crash. If I put the setText in othe function works fine, but if i add this
in a handler the app crash.

It is only a small bit of code, but I can say you probably have some bad C++ somewhere in that class. :stuck_out_tongue:
The documentation and wiki can help, as well as a debugger.

To forget to register new Component classes can cause crashes.
github.com/urho3d/Urho3D/blob/m … mo.cpp#L59

Assuming the demo does not crash, you might study it for something else missed.

Thanks again! :wink:
I’ll keep trying


WORKS!!! :smiley: