Skip to content

Commit

Permalink
Fix issue saving configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dliedke committed Oct 20, 2024
1 parent 96bd141 commit 81ae5be
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions KeyConfigForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private void TextBox_KeyDown(object sender, KeyEventArgs e)
if (IsUnique(displayValue, textBox))
{
textBox.Text = displayValue;
textBox.Tag = e.KeyCode; // Set the Tag for keyboard inputs
isListening = false;
isFirstClick = true;
e.Handled = true;
Expand Down Expand Up @@ -146,6 +147,7 @@ private void TextBox_MouseDown(object sender, MouseEventArgs e)
if (!string.IsNullOrEmpty(clickAction) && IsUnique(clickAction, textBox))
{
textBox.Text = clickAction;
textBox.Tag = null; // Clear the Tag for mouse clicks
isListening = false;
isFirstClick = true;
}
Expand Down Expand Up @@ -241,8 +243,17 @@ private void btnSave_Click(object sender, EventArgs e)
var property = settings.GetType().GetProperty(kvp.Key);
if (property != null)
{
// Use the Tag if it's set (for mouse clicks), otherwise use the Text
string value = kvp.Value.Tag != null ? kvp.Value.Tag.ToString() : kvp.Value.Text;
string value;
if (kvp.Value.Tag != null)
{
// For keyboard inputs, use the Keys enum value
value = ((Keys)kvp.Value.Tag).ToString();
}
else
{
// For mouse clicks, use the text directly
value = kvp.Value.Text;
}
property.SetValue(settings, value);
}
}
Expand Down

0 comments on commit 81ae5be

Please sign in to comment.