Browse Source

Merge pull request #532 from tig/text_scenario

demos text-based controls to show TAB behavior
Charlie Kindel 5 năm trước cách đây
mục cha
commit
a8bb7e82e1

+ 1 - 1
UICatalog/Scenarios/ComputedLayout.cs

@@ -23,7 +23,7 @@ namespace UICatalog {
 			const string rule = "|123456789";
 			var horizontalRuler = new Label ("") {
 				X = 0,
-				Y = 0,
+				Y = 0,		
 				Width = Dim.Fill (1),  // BUGBUG: I don't think this should be needed; DimFill() should respect container's frame. X does.
 				ColorScheme = Colors.Error
 			};

+ 8 - 12
UICatalog/Scenarios/HexEditor.cs

@@ -14,6 +14,10 @@ namespace UICatalog {
 
 		public override void Setup ()
 		{
+			Win.Title = this.GetName() + "-" + _fileName ?? "Untitled";
+			Win.Y = 1;
+			Top.LayoutSubviews ();
+
 			var menu = new MenuBar (new MenuBarItem [] {
 				new MenuBarItem ("_File", new MenuItem [] {
 					new MenuItem ("_New", "", () => New()),
@@ -40,28 +44,20 @@ namespace UICatalog {
 
 			CreateDemoFile (_fileName);
 
-			Win = new Window (_fileName ?? "Untitled") {
-				X = 0,
-				Y = 1,
-				Width = Dim.Fill (),
-				Height = Dim.Fill ()
-			};
-			Top.Add (Win);
-
 			_hexView = new HexView (LoadFile()) {
 				X = 0,
 				Y = 0,
 				Width = Dim.Fill (),
 				Height = Dim.Fill (),
 			};
-
-
+			_hexView.CanFocus = true;
 			Win.Add (_hexView);
 		}
 
 		private void New ()
 		{
-			Win.Title = _fileName = "Untitled";
+			_fileName = null;
+			Win.Title = this.GetName () + "-" + _fileName ?? "Untitled";
 			throw new NotImplementedException ();
 		}
 
@@ -75,7 +71,7 @@ namespace UICatalog {
 			if (_fileName != null) {
 				var bin = System.IO.File.ReadAllBytes (_fileName);
 				stream = new MemoryStream (bin);
-				Win.Title = _fileName;
+				Win.Title = this.GetName () + "-" + _fileName;
 				_saved = true;
 			}
 			return stream;

+ 59 - 0
UICatalog/Scenarios/Text.cs

@@ -0,0 +1,59 @@
+using System.Text;
+using Terminal.Gui;
+
+namespace UICatalog {
+	[ScenarioMetadata (Name: "Text Input Controls", Description: "Tests all text input controls")]
+	[ScenarioCategory ("Controls")]
+	[ScenarioCategory ("Bug Repro")]
+	class Text : Scenario {
+		public override void Setup ()
+		{
+			var s = "This is a test intended to show how TAB key works (or doesn't) across text fields.";
+			Win.Add (new TextField (s) {
+				X = 5,
+				Y = 1,
+				Width = Dim.Percent (80),
+				ColorScheme = Colors.Dialog
+			});
+
+			var textView = new TextView () {
+				X = 5,
+				Y = 3,
+				Width = Dim.Percent (80),
+				Height = Dim.Percent (40),
+				ColorScheme = Colors.Dialog
+			};
+			textView.Text = s;
+			Win.Add (textView);
+
+			// BUGBUG: 531 - TAB doesn't go to next control from HexView
+			var hexView = new HexView (new System.IO.MemoryStream(Encoding.ASCII.GetBytes (s))) {
+				X = 5,
+				Y = Pos.Bottom(textView) + 1,
+				Width = Dim.Percent(80),
+				Height = Dim.Percent(40),
+				ColorScheme = Colors.Dialog
+			};
+			Win.Add (hexView);
+
+			var dateField = new DateField (System.DateTime.Now) {
+				X = 5,
+				Y = Pos.Bottom (hexView) + 1,
+				Width = Dim.Percent (40),
+				ColorScheme = Colors.Dialog,
+				IsShortFormat = false
+			};
+			Win.Add (dateField);
+
+			var timeField = new TimeField (System.DateTime.Now) {
+				X = Pos.Right(dateField) + 5,
+				Y = Pos.Bottom (hexView) + 1,
+				Width = Dim.Percent (40),
+				ColorScheme = Colors.Dialog,
+				IsShortFormat = false
+			};
+			Win.Add (timeField);
+
+		}
+	}
+}