protected override void OnMouseDown(UIMouseDownEventArgs e) { //check what item is selected if (e.SourceHitElement is ListItem src) { //make this as current selected list item //find index ? //TODO: review, for faster find list item index method int found = -1; for (int i = _items.Count - 1; i >= 0; --i) { if (_items[i] == src) { found = i; break; } } if (found > -1) { SelectedIndex = found; } ListItemMouseEvent?.Invoke(this, e); } base.OnMouseDown(e); }
void IEventPortal.PortalMouseDown(UIMouseDownEventArgs e) { //find hit svg graphics.... VgHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(e.X, e.Y); //1. hit test HitTestCore(this.SvgRoot.SvgDoc.Root, hitChain, e.X, e.Y); SetEventOrigin(e, hitChain); //2. propagate event portal ForEachOnlyEventPortalBubbleUp(e, hitChain, portal => { portal.PortalMouseDown(e); return(true); }); if (!e.CancelBubbling) { //2. propagate events ForEachSvgElementBubbleUp(e, hitChain, () => { //------- //temp test only //------- var svgElement = e.ExactHitObject as SvgElement; //if (svgElement is SvgRect) //{ // ((SvgRect)svgElement).FillColor = Color.White; //} return(true); }); } e.CancelBubbling = true; ReleaseHitChain(hitChain); }
protected override void OnMouseDown(UIMouseDownEventArgs e) { ////test only!!! _lastX = e.X; _lastY = e.Y; _pointList.Add(new Point(_lastX, _lastY)); }
internal override void ListenMouseDown(object sender, UIMouseDownEventArgs e) { if (_ownerBeh.HasMouseDown) { _ownerBeh.InvokeMouseDown((S)sender, _state, e); } }
private void Box_MouseDown(object sender, UIMouseDownEventArgs e) { if (sender is Box box) { #if DEBUG box.CurrentPrimaryRenderElement.dbugBreak = true; #endif box.BackColor = PixelFarm.Drawing.Color.White; } }
public TopWindowEventRoot(RootGraphic rootgfx, TopWindowRenderBox topRenderElement) { _mouseDownEventArgs = new UIMouseDownEventArgs(); _mouseMoveEventArgs = new UIMouseMoveEventArgs(); _mouseUpEventArgs = new UIMouseUpEventArgs(); _wheelEventArgs = new UIMouseWheelEventArgs(); _topWinBoxEventPortal = new RenderElementEventPortal(topRenderElement); #if DEBUG _topWinBoxEventPortal.dbugRootGraphics = (MyRootGraphic)rootgfx; #endif _iTopBoxEventPortal = _topWinBoxEventPortal; _rootgfx = rootgfx; _hoverMonitoringTask = new UIHoverMonitorTask(); _hoverMonitoringTask.Interval = 100;//ms _hoverMonitoringTask.Enabled = true; UIPlatform.RegisterTimerTask(_hoverMonitoringTask); }
public virtual void HandleMouseDown(UIMouseDownEventArgs e) { if (e.Buttons == UIMouseButtons.Left) { InvalidateGraphicOfCurrentLineArea(); if (!e.Shift) { _editSession.SetCaretPos(e.X, e.Y); if (_editSession.SelectionRange != null) { Rectangle r = GetSelectionUpdateArea(); _editSession.CancelSelect(); InvalidateGraphics(r); } else { InvalidateGraphicOfCurrentLineArea(); } if (_editSession.LatestHitRun is SolidRun latestHitSolidTextRun && latestHitSolidTextRun.ExternalRenderElement?.GetController() is LayoutFarm.UI.IUIEventListener listener) { //we mousedown on the solid text run listener.ListenMouseDown(e); } } else { _editSession.StartSelectIfNoSelection(); _editSession.SetCaretPos(e.X, e.Y); _editSession.EndSelect(); InvalidateGraphicOfCurrentLineArea(); } } }
//handle event protected override void OnMouseDown(UIMouseDownEventArgs e) { _demoBase.MouseDown(e.X, e.Y, e.Buttons == UIMouseButtons.Right); base.OnMouseDown(e); }
void IEventListener.ListenMouseDown(UIMouseDownEventArgs e) { OnMouseDown(e); }
void IEventListener.ListenMouseDown(UIMouseDownEventArgs e) { MouseDown?.Invoke(this, e); }
protected override void OnMouseDown(UIMouseDownEventArgs e) { base.OnMouseDown(e); }
public void MouseDown(UIMouseDownEventArgs e) { this.MouseDown(e, _htmlVisualRoot.RootCssBox); }
void IEventListener.ListenMouseDown(UIMouseDownEventArgs e) { OnMouseDown(e); _externalEventListener?.ListenMouseDown(e); }
internal void InvokeMouseDown(S sender, T state, UIMouseDownEventArgs e) { MouseDown.Invoke(new SenderInfo(sender, state), e); }
internal abstract void ListenMouseDown(object sender, UIMouseDownEventArgs e);
void IEventPortal.PortalMouseDown(UIMouseDownEventArgs e) { #if DEBUG if (this.dbugRootGraphics != null && this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace) { this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================"); this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEDOWN"); this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================"); } dbugMsgChainVersion = 1; int local_msgVersion = 1; #endif HitChain hitPointChain = GetFreeHitChain(); #if DEBUG _dbugHitChainPhase = dbugHitChainPhase.MouseDown; #endif HitTestCoreWithPrevChainHint(hitPointChain, _previousChain, e.X, e.Y); if (hitPointChain.Count > 0) { //------------------------------ //1. origin object SetEventOrigin(e, hitPointChain); //------------------------------ _currentMouseDown = null; //portal ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (e1, portal) => { //please ensure=> no local var/pararmeter capture inside lambda portal.PortalMouseDown(e1); //***** _currentMouseDown = e1.CurrentContextElement; return(true); }); //------------------------------ //use events if (!e.CancelBubbling) { _currentMouseDown = null; //clear e.SetCurrentContextElement(null); ForEachEventListenerBubbleUp(e, hitPointChain, (e1, listener) => { //please ensure=> no local var/pararmeter capture inside lambda if (listener.BypassAllMouseEvents) { return(false); } _currentMouseDown = listener; listener.ListenMouseDown(e1); //------------------------------------------------------- //auto begin monitor mouse press _mousePressMonitor.AddMousePressInformation(e1); _mousePressMonitor.SetMonitoredElement(listener); //------------------------------------------------------- bool cancelMouseBubbling = e1.CancelBubbling; if (_prevMouseDownElement != null && _prevMouseDownElement != listener) { _prevMouseDownElement.ListenLostMouseFocus(_mouseLostFocusArgs); _prevMouseDownElement = null;//clear } //------------------------------------------------------- //retrun true to stop this loop (no further bubble up) //return false to bubble this to upper control return(e1.CancelBubbling || !listener.BypassAllMouseEvents); }); if (_currentMouseDown == null) { _mousePressMonitor.Reset(); } } if (_prevMouseDownElement != _currentMouseDown && _prevMouseDownElement != null) { //TODO: review here, auto or manual _prevMouseDownElement.ListenLostMouseFocus(_mouseLostFocusArgs); _prevMouseDownElement = null; } } //--------------------------------------------------------------- #if DEBUG RootGraphic dbug_visualroot = this.dbugRootGraphics; if (dbug_visualroot != null && dbug_visualroot.dbug_RecordHitChain) { dbug_visualroot.dbug_rootHitChainMsg.Clear(); HitInfo hitInfo; for (int tt = hitPointChain.Count - 1; tt >= 0; --tt) { hitInfo = hitPointChain.GetHitInfo(tt); RenderElement ve = hitInfo.HitElemAsRenderElement; if (ve != null) { ve.dbug_WriteOwnerLayerInfo(dbug_visualroot, tt); ve.dbug_WriteOwnerLineInfo(dbug_visualroot, tt); string hit_info = new string('.', tt) + " [" + tt + "] " + "(" + hitInfo.point.X + "," + hitInfo.point.Y + ") " + ve.dbug_FullElementDescription(); dbug_visualroot.dbug_rootHitChainMsg.AddLast(new dbugLayoutMsg(ve, hit_info)); } } } #endif SwapHitChain(hitPointChain); e.StopPropagation(); //TODO: review this again #if DEBUG if (local_msgVersion != dbugMsgChainVersion) { return; } dbug_visualroot.dbugHitTracker.Write("stop-mousedown"); dbug_visualroot.dbugHitTracker.Play = false; #endif }
public void AddMousePressInformation(UIMouseDownEventArgs importInfo) { _mousePressEventArgs.Button = importInfo.Buttons; }
protected override void OnMouseDown(UIMouseDownEventArgs e) { _isMouseDown = true; base.OnMouseDown(e); }
public void MouseDown(UIMouseDownEventArgs e, CssBox startAt) { if (!_isBinded) { return; } if (startAt == null) { return; } //---------------------------------------------------- if (!e.Shift) { ClearPreviousSelection(); } if (_latestMouseDownChain != null) { ReleaseHitChain(_latestMouseDownChain); _latestMouseDownChain = null; } _lastDomLayoutVersion = _htmlVisualRoot.LayoutVersion; //---------------------------------------------------- int x = e.X; int y = e.Y; _mouseDownStartAt = startAt; _mousedownX = x; _mousedownY = y; CssBoxHitChain hitChain = GetFreeHitChain(); #if DEBUG hitChain.debugEventPhase = CssBoxHitChain.dbugEventPhase.MouseDown; #endif hitChain.SetRootGlobalPosition(x, y); //1. hittest BoxHitUtils.HitTest(startAt, x, y, hitChain); //2. propagate events SetEventOrigin(e, hitChain); ForEachOnlyEventPortalBubbleUp(e, hitChain, portal => { portal.PortalMouseDown(e); return(true); }); if (!e.CancelBubbling) { IUIEventListener prevMouseDownElement = _currentMouseDown; _currentMouseDown = null; //clear e.SetCurrentContextElement(null); ForEachEventListenerBubbleUp(e, hitChain, () => { //TODO: check accept keyboard _currentMouseDown = e.CurrentContextElement; e.CurrentContextElement.ListenMouseDown(e); if (prevMouseDownElement != null && prevMouseDownElement != _currentMouseDown) { prevMouseDownElement.ListenLostMouseFocus(_mouseLostFocus); } return(e.CancelBubbling); }); } //---------------------------------- //save mousedown hitchain _latestMouseDownChain = hitChain; }
protected override void OnMouseDown(UIMouseDownEventArgs e) { _hingeRel.ToggleOpenOrClose(); base.OnMouseDown(e); }