From 49818d305880a34048740fed4f934521636d0f05 Mon Sep 17 00:00:00 2001 From: miguel Date: Sat, 7 Apr 2018 17:50:46 -0400 Subject: [PATCH] [TextView] add mouse handling --- Terminal.Gui/Views/TextView.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 3946a4b26..4223a53c7 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -1050,26 +1050,29 @@ namespace Terminal.Gui { return null; } -#if false public override bool MouseEvent (MouseEvent ev) { - if (!ev.Flags.HasFlag (MouseFlags.Button1Clicked)) + if (!ev.Flags.HasFlag (MouseFlags.Button1Clicked)) { return false; + } if (!HasFocus) SuperView.SetFocus (this); - // We could also set the cursor position. - point = first + ev.X; - if (point > text.Length) - point = text.Length; - if (point < first) - point = 0; + if (ev.Y + topRow >= model.Count) { + currentRow = model.Count - topRow; + } else { + currentRow = ev.Y + topRow; + } + var r = GetCurrentLine (); + if (ev.X - leftColumn >= r.Count) + currentColumn = r.Count - leftColumn; + else + currentColumn = ev.X - leftColumn; - SetNeedsDisplay (); + PositionCursor (); return true; } -#endif } }