public virtual bool dispatchEvent (Event ev)
		{
			if (_evTarget != null) {
				return dispatchEvent(ev);
			} else {
				bool dispatched = false;
				if (_events != null) {
					List<EventListener> evList = null;
					if (_events.TryGetValue (ev.type, out evList)) {
						var l = evList.Count;
						for (var i = 0; i < l; i++) {
							var f = evList [i];
							f.callback(ev);
							dispatched = true;
						}
					}
				}
				return dispatched;
			}
		}
Exemple #2
0
		private void OnTextureReady (Event e)
		{
			this.dispatchEvent(new Event(Event.TEXTURE_READY)  );
		}
 public bool dispatchEvent(Event pEvent)
 {
     return false;
 }
		public virtual bool dispatchEvent (Event ev)
		{
			ev._target = _evTarget;

			if (_evRedirect != null) {
				return _evRedirect.dispatchEvent(ev);
			} else {
				bool dispatched = false;
                var evList = getListenersForEventType(ev.type);
                if (evList != null) {
                    // we store off the count here in case the callback adds a listener
                    var l = evList.Count;
                    for (var i = 0; i < l; i++) {
                        // cast callback to dynamic
                        Delegate callback = evList [i].callback;
                        // we perform a dynamic invoke here because the parameter types dont always match exactly
                        try {
							// set current target for event
							ev._currentTarget = _evTarget;
							var args = PlayScript.Dynamic.ConvertArgumentList(callback.Method, new object[] {ev});
                            callback.DynamicInvoke(args);
                        } 
                        catch (Exception e)
                        {
                            // if you get an exception here while debugging then make sure that the debugger is setup to catch all exceptions
                            // this is in the Run/Exceptions... menu in MonoDevelop or Xamarin studio
							Console.Error.WriteLine(e.ToString());
                        }
                        dispatched = true;
                    }
                }
				return dispatched;
			}
		}
		public virtual bool dispatchEvent (Event ev)
		{
			if (_evTarget != null) {
				return dispatchEvent(ev);
			} else {
				bool dispatched = false;
                var evList = getListenersForEventType(ev.type);
                if (evList != null) {
                    // we store off the count here in case the callback adds a listener
                    var l = evList.Count;
                    for (var i = 0; i < l; i++) {
                        // cast callback to dynamic
                        Delegate callback = evList [i].callback;
                        // we perform a dynamic invoke here because the parameter types dont always match exactly
                        try {
							// set current target for event
							ev._currentTarget = ev._target = this;
                            callback.DynamicInvoke(ev);
							ev._currentTarget = ev._target = null;
                        } 
                        catch (Exception)
                        {
                            // if you get an exception here while debugging then make sure that the debugger is setup to catch all exceptions
                            // this is in the Run/Exceptions... menu in MonoDevelop or Xamarin studio
                        }
                        dispatched = true;
                    }
                }
				return dispatched;
			}
		}