mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Add scenario support for flipping button order
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user