Browse Source

Closes #973. ScrollView and TextField fixes.

BDisp 4 years ago
parent
commit
0fc29ada9f
2 changed files with 11 additions and 4 deletions
  1. 2 2
      FSharpExample/Program.fs
  2. 9 2
      Terminal.Gui/Views/TextField.cs

+ 2 - 2
FSharpExample/Program.fs

@@ -27,7 +27,7 @@ type Box10x (x: int, y: int) =
         raise (NotImplementedException())
         raise (NotImplementedException())
 
 
     override this.Redraw (_: Rect) =
     override this.Redraw (_: Rect) =
-        Application.Driver.SetAttribute Application.Current.ColorScheme.Focus
+        Application.Driver.SetAttribute this.ColorScheme.Focus
         do
         do
         let mutable y = 0
         let mutable y = 0
         while y < h do
         while y < h do
@@ -47,7 +47,7 @@ type Filler (rect: Rect) =
         new Filler ()
         new Filler ()
 
 
     override this.Redraw (_: Rect) =
     override this.Redraw (_: Rect) =
-        Application.Driver.SetAttribute Application.Current.ColorScheme.Focus
+        Application.Driver.SetAttribute this.ColorScheme.Focus
         let mutable f = this.Frame
         let mutable f = this.Frame
         do
         do
         let mutable y = 0
         let mutable y = 0

+ 9 - 2
Terminal.Gui/Views/TextField.cs

@@ -48,13 +48,13 @@ namespace Terminal.Gui {
 		/// <param name="text">Initial text contents.</param>
 		/// <param name="text">Initial text contents.</param>
 		public TextField (string text) : this (ustring.Make (text))
 		public TextField (string text) : this (ustring.Make (text))
 		{
 		{
-			Height = 1;
+			Initialize ();
 		}
 		}
 
 
 		/// <summary>
 		/// <summary>
 		/// Initializes a new instance of the <see cref="TextField"/> class using <see cref="LayoutStyle.Computed"/> positioning.
 		/// Initializes a new instance of the <see cref="TextField"/> class using <see cref="LayoutStyle.Computed"/> positioning.
 		/// </summary>
 		/// </summary>
-		public TextField () : this (string.Empty) { }
+		public TextField () : this (string.Empty) { Initialize (); }
 
 
 		/// <summary>
 		/// <summary>
 		/// Initializes a new instance of the <see cref="TextField"/> class using <see cref="LayoutStyle.Computed"/> positioning.
 		/// Initializes a new instance of the <see cref="TextField"/> class using <see cref="LayoutStyle.Computed"/> positioning.
@@ -80,6 +80,8 @@ namespace Terminal.Gui {
 
 
 		void Initialize (ustring text, int w)
 		void Initialize (ustring text, int w)
 		{
 		{
+			Initialize ();
+
 			if (text == null)
 			if (text == null)
 				text = "";
 				text = "";
 
 
@@ -91,6 +93,11 @@ namespace Terminal.Gui {
 			WantMousePositionReports = true;
 			WantMousePositionReports = true;
 		}
 		}
 
 
+		void Initialize ()
+		{
+			Height = 1;
+		}
+
 		///<inheritdoc/>
 		///<inheritdoc/>
 		public override bool OnLeave (View view)
 		public override bool OnLeave (View view)
 		{
 		{