2
0

runtime.cpp 769 B

12345678910111213141516171819202122232425262728
  1. #include "../AllUrho.h"
  2. //
  3. // This is a notification that posts the message to a general function, does
  4. // not have to be an Urho object
  5. //
  6. class FuncNotification : public Urho3D::EventHandler {
  7. typedef void (*HandlerFunctionPtr)(void *data, Urho3D::StringHash, Urho3D::VariantMap&);
  8. public:
  9. FuncNotification (Urho3D::Object *receiver, HandlerFunctionPtr func, void *data) : EventHandler(receiver, data), theFunc(func){}
  10. virtual void Invoke(Urho3D::VariantMap& eventData)
  11. {
  12. (*theFunc)(userData_, eventType_, eventData);
  13. }
  14. virtual Urho3D::EventHandler* Clone() const
  15. {
  16. FuncNotification *x = new FuncNotification(receiver_, theFunc, userData_);
  17. x->SetSenderAndEventType (sender_, eventType_);
  18. return x;
  19. }
  20. protected:
  21. HandlerFunctionPtr theFunc;
  22. };