diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index aa6b69558..ae886f627 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -648,11 +648,16 @@ namespace Terminal.Gui { this.btnToggleSplitterCollapse.Text = this.GetToggleSplitterText (false); if(Style.FlipOkCancelButtonLayoutOrder) { - var p1 = btnOk.X; - var p2 = btnCancel.X; + btnCancel.X = Pos.Function(this.CalculateOkButtonPosX); + btnOk.X = Pos.Right (btnCancel) + 1; - btnOk.X = p2; - btnCancel.X = p1; + + // Flip tab order too for consistency + var p1 = this.btnOk.TabIndex; + var p2 = this.btnCancel.TabIndex; + + this.btnOk.TabIndex = p2; + this.btnCancel.TabIndex = p1; } tbPath.Caption = Style.PathCaption; diff --git a/UICatalog/Scenarios/FileDialogExamples.cs b/UICatalog/Scenarios/FileDialogExamples.cs index e110d27a2..99ffb145d 100644 --- a/UICatalog/Scenarios/FileDialogExamples.cs +++ b/UICatalog/Scenarios/FileDialogExamples.cs @@ -25,6 +25,9 @@ namespace UICatalog.Scenarios { private RadioGroup rgIcons; private RadioGroup rgAllowedTypes; + private TextField tbOkButton; + private TextField tbCancelButton; + private CheckBox cbFlipButtonOrder; public override void Setup () { var y = 0; @@ -110,6 +113,25 @@ namespace UICatalog.Scenarios { rgAllowedTypes.RadioLabels = new string [] { "Any", "Csv (Recommended)", "Csv (Strict)" }; Win.Add (rgAllowedTypes); + y = 5; + x = 45; + + Win.Add (new LineView (Orientation.Vertical) { + X = x++, + Y = y + 1, + Height = 4 + }); + Win.Add (new Label ("Buttons") { X = x++, Y = y++ }); + + Win.Add(new Label("Ok Text:") { X = x, Y = y++ }); + tbOkButton = new TextField () { X = x, Y = y++, Width = 12 }; + Win.Add (tbOkButton); + Win.Add (new Label ("Cancel Text:") { X = x, Y = y++ }); + tbCancelButton = new TextField () { X = x, Y = y++, Width = 12 }; + Win.Add (tbCancelButton); + cbFlipButtonOrder = new CheckBox ("Flip Order") { X = x, Y = y++}; + Win.Add (cbFlipButtonOrder); + var btn = new Button ($"Run Dialog") { X = 1, Y = 9 @@ -178,6 +200,16 @@ namespace UICatalog.Scenarios { } + if (!string.IsNullOrWhiteSpace (tbOkButton.Text)) { + fd.Style.OkButtonText = tbOkButton.Text; + } + if (!string.IsNullOrWhiteSpace (tbCancelButton.Text)) { + fd.Style.CancelButtonText= tbCancelButton.Text; + } + if(cbFlipButtonOrder.Checked ?? false) { + fd.Style.FlipOkCancelButtonLayoutOrder = true; + } + Application.Run (fd); if (fd.Canceled) {