static void SetEventOrigin(UIEventArgs e, VgHitChain hitChain) { int count = hitChain.Count; if (count > 0) { VgHitInfo hitInfo = hitChain.GetHitInfo(count - 1); e.SetExactHitObject(hitInfo); } }
static void ForEachSvgElementBubbleUp(UIEventArgs e, VgHitChain hitChain, System.Func<bool> listenerAction) { for (int i = hitChain.Count - 1; i >= 0; --i) { //propagate up VgHitInfo hitInfo = hitChain.GetHitInfo(i); //--------------------- //hit on element e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (listenerAction()) { return; } } }
static void ForEachOnlyEventPortalBubbleUp(UIEventArgs e, VgHitChain hitPointChain, System.Func<IEventPortal, bool> eventPortalAction) { //only listener that need tunnel down for (int i = hitPointChain.Count - 1; i >= 0; --i) { //propagate up VgHitInfo hitInfo = hitPointChain.GetHitInfo(i); if (hitInfo.hitElem.GetController() is SvgElement svg && SvgElement.UnsafeGetController(svg) is IEventPortal controller) { e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (eventPortalAction(controller)) { return; } } } }
static void ForEachEventListenerBubbleUp(UIEventArgs e, VgHitChain hitChain, System.Func <bool> listenerAction) { for (int i = hitChain.Count - 1; i >= 0; --i) { //propagate up VgHitInfo hitInfo = hitChain.GetHitInfo(i); IUIEventListener controller = SvgElement.UnsafeGetController(hitInfo.GetSvgElement()) as IUIEventListener; //switch (hitInfo.hitObjectKind) //{ // default: // { // continue; // } // case HitObjectKind.Run: // { // CssRun run = (CssRun)hitInfo.hitObject; // controller = CssBox.UnsafeGetController(run.OwnerBox) as IEventListener; // } break; // case HitObjectKind.CssBox: // { // CssBox box = (CssBox)hitInfo.hitObject; // controller = CssBox.UnsafeGetController(box) as IEventListener; // } break; //} //--------------------- if (controller != null) { //found controller e.SetCurrentContextElement(controller); e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (listenerAction()) { return; } } } }