Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add setting to login dialog in order to change the focus from the username field to the password field when pressing enter #4529

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix property names
  • Loading branch information
Valmir-Cunha committed Oct 31, 2024
commit 247f75728e199ed0eb17c780406f51c33c5f0623
16 changes: 8 additions & 8 deletions src/MahApps.Metro/Controls/Dialogs/LoginDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ public bool RememberCheckBoxChecked
set => this.SetValue(RememberCheckBoxCheckedProperty, BooleanBoxes.Box(value));
}

/// <summary>Identifies the <see cref="ChangeFocusWithEnterOnUsernameField"/> dependency property.</summary>
public static readonly DependencyProperty ChangeFocusWithEnterOnUsernameFieldProperty
= DependencyProperty.Register(nameof(ChangeFocusWithEnterOnUsernameField),
/// <summary>Identifies the <see cref="ChangeFocusOnUsernameFieldWithEnterProperty"/> dependency property.</summary>
public static readonly DependencyProperty ChangeFocusOnUsernameFieldWithEnterProperty
= DependencyProperty.Register(nameof(ChangeFocusOnUsernameFieldWithEnter),
typeof(bool),
typeof(LoginDialog),
new PropertyMetadata(default(bool)));

public bool ChangeFocusWithEnterOnUsernameField
public bool ChangeFocusOnUsernameFieldWithEnter
{
get => (bool) this.GetValue(ChangeFocusWithEnterOnUsernameFieldProperty);
set => this.SetValue(ChangeFocusWithEnterOnUsernameFieldProperty, value);
get => (bool) this.GetValue(ChangeFocusOnUsernameFieldWithEnterProperty);
set => this.SetValue(ChangeFocusOnUsernameFieldWithEnterProperty, value);
}

#endregion DependencyProperties
Expand Down Expand Up @@ -270,7 +270,7 @@ internal LoginDialog(MetroWindow? parentWindow, LoginDialogSettings? settings)
this.SetCurrentValue(RememberCheckBoxVisibilityProperty, loginDialogSettings.RememberCheckBoxVisibility);
this.SetCurrentValue(RememberCheckBoxTextProperty, loginDialogSettings.RememberCheckBoxText);
this.SetCurrentValue(RememberCheckBoxCheckedProperty, loginDialogSettings.RememberCheckBoxChecked);
this.SetCurrentValue(ChangeFocusWithEnterOnUsernameFieldProperty, loginDialogSettings.ChangeFocusWithEnterOnUsernameField);
this.SetCurrentValue(ChangeFocusOnUsernameFieldWithEnterProperty, loginDialogSettings.ChangeFocusOnUsernameFieldWithEnter);
}
}

Expand Down Expand Up @@ -313,7 +313,7 @@ private void OnKeyDownHandler(object sender, KeyEventArgs e)
}
else if (e.Key == Key.Enter)
{
if (PART_TextBox != null && PART_TextBox.IsFocused && ChangeFocusWithEnterOnUsernameField)
if (PART_TextBox != null && PART_TextBox.IsFocused && ChangeFocusOnUsernameFieldWithEnter)
{
PART_PasswordBox?.Focus();
}
Expand Down
2 changes: 1 addition & 1 deletion src/MahApps.Metro/Controls/Dialogs/LoginDialogSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ public LoginDialogSettings(MetroDialogSettings? source)

public bool RememberCheckBoxChecked { get; set; } = false;

public bool ChangeFocusWithEnterOnUsernameField { get; set; } = false;
public bool ChangeFocusOnUsernameFieldWithEnter { get; set; } = false;
}
}