void SwapHitChain(HitChain hitChain) { if (_previousChain != null) { _hitChainStack.Push(_previousChain); } _previousChain = hitChain; //temp fix here _previousChain.Reset(); }
// static RenderElement HitTestOnPreviousChain(HitChain hitPointChain, HitChain previousChain, int x, int y) // { //#if DEBUG // if (hitPointChain == previousChain) // { // throw new NotSupportedException(); // } //#endif // if (previousChain.Count > 0) // { // previousChain.SetStartTestPoint(x, y); // //test on prev chain top to bottom // int j = previousChain.Count; // for (int i = 0; i < j; ++i) // { // HitInfo hitInfo = previousChain.GetHitInfo(i); // RenderElement elem = hitInfo.HitElemAsRenderElement; // if (elem != null && elem.VisibleAndHasParent) // { // if (elem.Contains(hitInfo.point)) // { // RenderElement found = elem.FindUnderlyingSiblingAtPoint(hitInfo.point); // if (found == null) // { // Point leftTop = elem.Location; // hitPointChain.OffsetTestPoint(leftTop.X, leftTop.Y); // hitPointChain.AddHitObject(elem); // //add to chain // } // else // { // break; // } // } // } // else // { // break; // } // } // } // //--------------------------------- // if (hitPointChain.Count > 0) // { // var commonElement = hitPointChain.GetHitInfo(hitPointChain.Count - 1).HitElemAsRenderElement; // hitPointChain.RemoveCurrentHit(); // return commonElement; // } // else // { // return null; // } // } void HitTestCoreWithPrevChainHint(HitChain hitChain, HitChain previousChain, int x, int y) { //--------------------------------- //test on previous chain first , find common element hitChain.Reset(); hitChain.SetStartTestPoint(x, y); #if DEBUG hitChain.dbugHitPhase = _dbugHitChainPhase; #endif //if (this.dbugId > 0 && isDragging && previousChain.Count > 1) //{ //} //RenderElement commonElement = HitTestOnPreviousChain(hitPointChain, previousChain, x, y); //temp fix //TODO: fix bug on HitTestOnPreviousChain() RenderElement commonElement = _topRenderElement; commonElement.HitTestCore(hitChain); //remove disable elements //if (hitPointChain.dbugHitPhase == dbugHitChainPhase.MouseDown) //{ int j = hitChain.Count; for (int i = 0; i < j; ++i) { HitInfo info = hitChain.GetHitInfo(i); RenderElement renderE = info.HitElemAsRenderElement; if (renderE != null && renderE.GetController() is IUIEventListener ui && !ui.Enabled) { HitChain.UnsafeClear(hitChain); break;//stop loop and exit } } //} }
void IEventPortal.PortalMouseMove(UIMouseMoveEventArgs e) { HitChain hitPointChain = GetFreeHitChain(); #if DEBUG _dbugHitChainPhase = dbugHitChainPhase.MouseMove; #endif HitTestCoreWithPrevChainHint(hitPointChain, _previousChain, e.X, e.Y); _previousChain.Reset(); SetEventOrigin(e, hitPointChain); //------------------------------------------------------- ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (e1, portal) => { //please ensure=> no local var/pararmeter capture inside lambda portal.PortalMouseMove(e1); return(true); }); //------------------------------------------------------- if (!e.CancelBubbling) { _mouseMoveFoundSomeHit = false; _mouseMoveFoundLastMouseActive = false; ForEachEventListenerBubbleUp(e, hitPointChain, (e1, listener) => { //please ensure=> no local var/pararmeter capture inside lambda _mouseMoveFoundSomeHit = true; #if DEBUG if (_dbugEnableDebugMark && e.Ctrl && e1.X <= 10 && e1.Y <= 10) { //show dbug info listener.dbugDevWriteInfo(); } #endif bool _bubble = true; //temp fix if (_latestMouseActive != listener && !_mouseMoveFoundLastMouseActive) { //---------- e1.CancelBubbling = _bubble; //temp fix listener.ListenMouseEnter(e1); _bubble = e1.CancelBubbling; //---------- if (_latestMouseActive != null) { _mouseLeaveEventArgs.SetCurrentContextElement(_latestMouseActive); UIMouseLeaveEventArgs.SetDiff(_mouseLeaveEventArgs, e1.XDiff, e1.YDiff); _latestMouseActive.ListenMouseLeave(_mouseLeaveEventArgs); } _latestMouseActive = listener; } if (!e1.IsCanceled) { //TODO: review here e1.CancelBubbling = _bubble; //temp fix listener.ListenMouseMove(e1); if (!_mouseMoveFoundLastMouseActive) { _latestMouseActive = e1.CurrentContextElement; } } if (!e1.CancelBubbling) { _mouseMoveFoundLastMouseActive = true; } return(e1.CancelBubbling); }); if (!_mouseMoveFoundSomeHit) { if (_latestMouseActive != null) { _mouseLeaveEventArgs.IsDragging = e.IsDragging; UIMouseLeaveEventArgs.SetDiff(_mouseLeaveEventArgs, e.XDiff, e.YDiff); _mouseLeaveEventArgs.SetCurrentContextElement(_latestMouseActive); _latestMouseActive.ListenMouseLeave(_mouseLeaveEventArgs); _latestMouseActive = null; } } } SwapHitChain(hitPointChain); e.StopPropagation(); }