private bool TryHandleMouseEvent(IMouseEvent args) { var rect = cText.Node.GetComponent <IRectangleComponent>().Rectangle; var textBox = cText.TextBox; if (!args.RayHitResult.HasValue) { return(false); } var hmgnPoint = args.RayHitResult.Value.LocalHitPoint.Xy; var textBoxPoint = new Vector2( (1 + hmgnPoint.X) / 2 * rect.Width * textBox.PixelScaling, (1 - hmgnPoint.Y) / 2 * rect.Height * textBox.PixelScaling); var layout = textBox.Layout; if (layout.TryGetSpanAt(textBoxPoint, out var lspan) && lspan.Embedding != null && lspan.EmbeddingHandler != null && lspan.EmbeddingHandler.TryHandleMouseEvent(lspan.Embedding, args)) { return(true); } if (args.IsLeftDownEvent()) { var newPos = layout.GetPosition(textBoxPoint); HeadlessEditor.MoveCursor(newPos, args.KeyModifiers == KeyModifiers.Shift); inputHandler.AddLock(new InputLock <object>(null, MouseDownLockProc)); return(true); } return(false); }
private bool TryHandleMouseEvent(IMouseEvent args) { if (args.IsLeftDownEvent()) { inputHandler.AddLock(new ResizeRectangleInputLock(getRectAspect(master), undoRedo, getSpace(master), getPlace(master))); return(true); } return(false); }
private bool TryHandleMouseEvent(IMouseEvent args) { if (args.IsLeftDownEvent()) { var rectAspect = getRectAspect(master); var space = getSpace(master); var globalRay = args.Viewport.GetGlobalRayForPixelPos(args.State.Position); if (!space.TryFindPoint2D(globalRay, out var initialPoint)) { return(false); } //if (rectAspect.Rectangle.DistanceToBorderFrom(initialPoint) > 0.05f) // return false; var anchor = initialPoint - rectAspect.Rectangle.MinMin; inputHandler.AddLock(new DragRectangleInputLock(undoRedo, rectAspect, space, anchor)); return(true); } return(false); }
private bool TryHandleMouseEvent(IMouseEvent eventArgs) { if (state == State.Ready && eventArgs.IsLeftDownEvent()) { state = State.Drawing; AddPointIfPossible(eventArgs.Viewport, eventArgs.State.Position); return(true); } if (state == State.Drawing && eventArgs.IsOfType(MouseEventType.Move)) { AddPointIfPossible(eventArgs.Viewport, eventArgs.State.Position); return(true); } if (state == State.Drawing && eventArgs.IsLeftUpEvent()) { AddPointIfPossible(eventArgs.Viewport, eventArgs.State.Position); AdjustRectangleAndSetCurve(); richTextAspect.BorderComplete = true; state = State.Finished; return(true); } return(false); }
public bool TryHandleMouseEvent(IMouseEvent args) { if (!isDrawing) { if (args.IsLeftDownEvent() && args.KeyModifiers == KeyModifiers.Shift) { isDrawing = true; var newSketch = new List <Vector2>(); newSketch.Add(args.State.HmgnPosition); sketches.Add(newSketch); return(true); } if (args.IsRightClickEvent() && args.KeyModifiers == KeyModifiers.Shift) { if (sketches.Any()) { sketches.RemoveAt(sketches.Count - 1); } return(true); } } else { if (args.IsLeftUpEvent() || args.KeyModifiers != KeyModifiers.Shift) { sketches.Last().Add(args.State.HmgnPosition); isDrawing = false; return(true); } if (args.IsOfType(MouseEventType.Move)) { sketches.Last().Add(args.State.HmgnPosition); return(true); } } return(false); }