EventHandler.lua 582 B

1234567891011121314151617181920212223242526272829303132333435
  1. class "EventHandler"
  2. function EventHandler:EventHandler(...)
  3. for k,v in pairs(arg) do
  4. if type(v) == "table" then
  5. if v.__ptr ~= nil then
  6. arg[k] = v.__ptr
  7. end
  8. end
  9. end
  10. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  11. self.__ptr = Polycore.EventHandler(self)
  12. Polycore.__ptr_lookup[self.__ptr] = self
  13. end
  14. end
  15. function EventHandler:__delete()
  16. Polycore.__ptr_lookup[self.__ptr] = nil
  17. Polycore.delete_EventHandler(self.__ptr)
  18. end
  19. function EventHandler:__handleEvent(event)
  20. evt = Event("__skip_ptr__")
  21. evt.__ptr = event
  22. self:handleEvent(evt)
  23. end