Skip to content

Commit

Permalink
Fix focus issues
Browse files Browse the repository at this point in the history
When passwords in Key Prompt and Key Creation / Key Change form are shown in plaintext initially (UIFlags),
the password field was not focused properly.
This release provides a fix for that

Closes #11
  • Loading branch information
Rookiestyle committed Sep 14, 2021
1 parent d31106f commit 5219f98
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
30 changes: 29 additions & 1 deletion src/ColoredSecureTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ internal sealed class ColoredSecureTextBox : SecureTextBoxEx

private bool m_bKeeTheme = false;

private Form m_form = null;

public ColoredSecureTextBox()
{
if (DesignMode) return;
Expand All @@ -62,7 +64,33 @@ public ColoredSecureTextBox()
private void M_text_ParentChanged(object sender, EventArgs e)
{
m_bKeeTheme = (m_text.Parent != null) && m_text.Parent.GetType().FullName.Contains("KeeTheme");
}

//https://github.com/Rookiestyle/ColoredPassword/issues/11
//
//If passwords are shon in plaintext, ColoredPassword
//replaces the password text box with a RichTextBox
//
//KeePass itself checks m_tbPassword.CanFocus which is false
//in that case and by that, KeePass does not focuses the password field
if (m_form != null) m_form.Shown -= CorrectFocus;
m_form = FindForm() as KeePass.Forms.KeyPromptForm;
if (m_form == null) m_form = FindForm() as KeePass.Forms.KeyCreationForm;
if (m_form != null) m_form.Shown += CorrectFocus;
}

private void CorrectFocus(object sender, EventArgs e)
{
ulong uUIFlags = 0;
if (m_form is KeePass.Forms.KeyPromptForm)
uUIFlags = KeePass.Program.Config.UI.KeyPromptFlags;
else if (m_form is KeePass.Forms.KeyCreationForm)
uUIFlags = KeePass.Program.Config.UI.KeyCreationFlags;
else return;

if ((uUIFlags & (ulong)KeePass.App.Configuration.AceKeyUIFlags.UncheckHidePassword) == 0) return;

if (Enabled) UIUtil.ResetFocus(this, m_form, true);
}

private void ColoredSecureTextBox_SizeChanged(object sender, EventArgs e)
{
Expand Down
6 changes: 4 additions & 2 deletions src/PluginTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ private static string InitTranslation(Plugin plugin, List<string> lDebugStrings,
}
catch (Exception ex)
{
lDebugStrings.Add("Error parsing file: " + ex.Message);
string sException = ex.Message;
if (ex.InnerException != null) sException += "\n" + ex.InnerException.Message;
lDebugStrings.Add("Error parsing file: " + sException);
LanguageCodeIso6391 = "en";
MessageBox.Show("Error parsing translation file\n" + ex.Message, PluginName, MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Error parsing translation file\n\n" + sException, PluginName, MessageBoxButtons.OK, MessageBoxIcon.Error);
bError = true;
return LanguageCodeIso6391;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.13")]
[assembly: AssemblyFileVersion("0.13")]
[assembly: AssemblyVersion("0.13.1")]
[assembly: AssemblyFileVersion("0.13.1")]
2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:
ColoredPassword:0.13
ColoredPassword:0.13.1
ColoredPassword!de:5
ColoredPassword!pl:2
ColoredPassword!pt:1
Expand Down

0 comments on commit 5219f98

Please sign in to comment.