public override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (this.mouseSelect) { Cursor.Current = Cursors.IBeam; // Pick char int pickedCharIndex; Point pickLoc = new Point(Math.Min(Math.Max(e.X, rect.X + 2), rect.Right - 2), rect.Y + rect.Height / 2); pickedCharIndex = ControlRenderer.PickCharTextField( this.rect, this.text, ControlRenderer.DefaultFont, TextBoxStyle.Sunken, pickLoc, this.scroll); if (pickedCharIndex == -1) pickedCharIndex = this.text != null ? this.text.Length : 0; this.selectionLength = (this.cursorIndex + this.selectionLength) - pickedCharIndex; this.cursorIndex = pickedCharIndex; this.UpdateScroll(); this.EmitInvalidate(); } else { if (!this.rect.Contains(e.Location)) return; Cursor.Current = this.hovered && (Control.MouseButtons == MouseButtons.None) ? Cursors.IBeam : Cursors.Default; } }
public void OnMouseDown(MouseEventArgs e) { if (!this.rect.Contains(e.Location)) { return; } // Pick char int pickedCharIndex; Point pickLoc = new Point(Math.Min(Math.Max(e.X, rect.X + 2), rect.Right - 2), rect.Y + rect.Height / 2); pickedCharIndex = ControlRenderer.PickCharTextField( this.rect, this.text, ControlRenderer.FontRegular, TextBoxStyle.Sunken, pickLoc, this.scroll); if (pickedCharIndex == -1) { pickedCharIndex = this.text != null ? this.text.Length : 0; } this.cursorIndex = pickedCharIndex; this.selectionLength = 0; this.UpdateScroll(); this.EmitInvalidate(); this.mouseSelect = true; }