|
7 | 7 | using Terminal.Gui.Configuration; |
8 | 8 | using Terminal.Gui.Drawing; |
9 | 9 | using Terminal.Gui.Drivers; |
| 10 | +using Terminal.Gui.Editor; |
10 | 11 | using Terminal.Gui.Resources; |
11 | 12 | using Terminal.Gui.ViewBase; |
12 | 13 | using Terminal.Gui.Views; |
|
60 | 61 | mainWindow.Add (textFieldButton); |
61 | 62 |
|
62 | 63 | // Example 1: TextField with string result using auto-Text extraction |
63 | | -Button textViewButton = new () { Title = "TextView (Auto-Text)", X = Pos.Center (), Y = buttonY++ }; |
| 64 | +Button editorButton = new () { Title = "Editor (Auto-Text)", X = Pos.Center (), Y = buttonY++ }; |
64 | 65 |
|
65 | | -textViewButton.Accepting += (_, _) => |
66 | | - { |
67 | | - string? result = mainWindow.Prompt<TextView, string> (beginInitHandler: prompt => |
68 | | - { |
69 | | - prompt.Title = textViewButton.Title; |
| 66 | +editorButton.Accepting += (_, _) => |
| 67 | + { |
| 68 | + string? result = mainWindow.Prompt<Editor, string> (beginInitHandler: prompt => |
| 69 | + { |
| 70 | + prompt.Title = editorButton.Title; |
70 | 71 |
|
71 | | - prompt.GetWrappedView ().Text = |
72 | | - "Some text\nis nice."; |
73 | | - prompt.GetWrappedView ().Width = Dim.Fill (0, 40); |
74 | | - prompt.GetWrappedView ().Height = Dim.Fill (0, 8); |
| 72 | + prompt.GetWrappedView ().Text = "Some text\nis nice."; |
| 73 | + prompt.GetWrappedView ().Width = Dim.Fill (0, 40); |
| 74 | + prompt.GetWrappedView ().Height = Dim.Fill (0, 8); |
75 | 75 |
|
76 | | - if (!string.IsNullOrEmpty (initialValueField.Text)) |
77 | | - { |
78 | | - ((IValue)prompt.GetWrappedView ()) |
79 | | - .TrySetValueFromString (initialValueField |
80 | | - .Text); |
81 | | - } |
82 | | - }); |
| 76 | + if (!string.IsNullOrEmpty (initialValueField.Text)) |
| 77 | + { |
| 78 | + ((IValue)prompt.GetWrappedView ()) |
| 79 | + .TrySetValueFromString (initialValueField.Text); |
| 80 | + } |
| 81 | + }); |
83 | 82 |
|
84 | | - MessageBox.Query (app, textViewButton.Title, result is { } ? $"You entered: {result}" : "Canceled", Strings.btnOk); |
85 | | - }; |
| 83 | + MessageBox.Query (app, editorButton.Title, result is { } ? $"You entered: {result}" : "Canceled", Strings.btnOk); |
| 84 | + }; |
86 | 85 |
|
87 | | -mainWindow.Add (textViewButton); |
| 86 | +mainWindow.Add (editorButton); |
88 | 87 |
|
89 | 88 | // Example 2: DatePicker with DateTime result |
90 | 89 | Button datePickerButton = new () { Title = "DatePicker (Typed Result)", X = Pos.Center (), Y = buttonY++ }; |
@@ -297,7 +296,7 @@ FormData ExtractFormData (View form) |
297 | 296 | // Result type for custom form |
298 | 297 | internal record FormData |
299 | 298 | { |
300 | | - public string Name { get; init; } = string.Empty; |
301 | 299 | public int Age { get; init; } |
302 | 300 | public bool Agreed { get; init; } |
| 301 | + public string Name { get; init; } = string.Empty; |
303 | 302 | } |
0 commit comments