EventDispatcher.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. require('Polycode/EventHandler')
  2. function EventDispatcher() {
  3. if(arguments[0] != "__skip_ptr__") {
  4. this.__ptr = Polycode.EventDispatcher()
  5. }
  6. }
  7. EventDispatcher.prototype = Object.create(EventHandler.prototype);
  8. Duktape.fin(EventDispatcher.prototype, function (x) {
  9. if (x === EventDispatcher.prototype) {
  10. return;
  11. }
  12. Polycode.EventDispatcher__delete(x.__ptr)
  13. })
  14. EventDispatcher.prototype.removeAllHandlers = function() {
  15. Polycode.EventDispatcher_removeAllHandlers(this.__ptr)
  16. }
  17. EventDispatcher.prototype.removeAllHandlersForListener = function(handler) {
  18. Polycode.EventDispatcher_removeAllHandlersForListener(this.__ptr, handler.__ptr)
  19. }
  20. EventDispatcher.prototype.addEventListener = function(handler,eventCode) {
  21. Polycode.EventDispatcher_addEventListener(this.__ptr, handler.__ptr, eventCode)
  22. }
  23. EventDispatcher.prototype.addEventListenerUnique = function(handler,eventCode) {
  24. Polycode.EventDispatcher_addEventListenerUnique(this.__ptr, handler.__ptr, eventCode)
  25. }
  26. EventDispatcher.prototype.hasEventListener = function(handler,eventCode) {
  27. return Polycode.EventDispatcher_hasEventListener(this.__ptr, handler.__ptr, eventCode)
  28. }
  29. EventDispatcher.prototype.removeEventListener = function(handler,eventCode) {
  30. Polycode.EventDispatcher_removeEventListener(this.__ptr, handler.__ptr, eventCode)
  31. }
  32. EventDispatcher.prototype.__dispatchEvent = function(event,eventCode) {
  33. Polycode.EventDispatcher___dispatchEvent(this.__ptr, event.__ptr, eventCode)
  34. }
  35. EventDispatcher.prototype.dispatchEvent = function(event,eventCode) {
  36. Polycode.EventDispatcher_dispatchEvent(this.__ptr, event.__ptr, eventCode)
  37. }
  38. EventDispatcher.prototype.dispatchEventNoDelete = function(event,eventCode) {
  39. Polycode.EventDispatcher_dispatchEventNoDelete(this.__ptr, event.__ptr, eventCode)
  40. }