瀏覽代碼

[TextField] update point to 0 or the lenght-1 on changes, fixes #150

miguel 6 年之前
父節點
當前提交
137417f768
共有 2 個文件被更改,包括 2 次插入1 次删除
  1. 1 0
      Example/demo.cs
  2. 1 1
      Terminal.Gui/Views/TextField.cs

+ 1 - 0
Example/demo.cs

@@ -106,6 +106,7 @@ static class Demo {
 			Y = Pos.Top (login),
 			Width = 40
 		};
+
 		var passText = new TextField ("") {
 			Secret = true,
 			X = Pos.Left (loginText),

+ 1 - 1
Terminal.Gui/Views/TextField.cs

@@ -95,7 +95,7 @@ namespace Terminal.Gui {
 			set {
 				text = TextModel.ToRunes (value);
 				if (point > text.Count)
-					point = text.Count;
+					point = Math.Max (text.Count-1, 0);
 
 				// FIXME: this needs to be updated to use Rune.ColumnWidth
 				first = point > Frame.Width ? point - Frame.Width : 0;