Fix Hex boxes in various dialogs to allow ctrl+C/A/V, such as game genie, cheats, ram watch/search, etc

This commit is contained in:
adelikat 2012-09-26 02:46:13 +00:00
parent d5fc8f1c89
commit 1a4962b8c8
9 changed files with 33 additions and 105 deletions

View File

@ -33,9 +33,9 @@
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.CompareBox = new System.Windows.Forms.TextBox(); this.CompareBox = new HexTextBox();
this.ValueBox = new System.Windows.Forms.TextBox(); this.ValueBox = new HexTextBox();
this.AddressBox = new System.Windows.Forms.TextBox(); this.AddressBox = new HexTextBox();
this.AddCheat = new System.Windows.Forms.Button(); this.AddCheat = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel(); this.ButtonPanel = new System.Windows.Forms.Panel();
this.N = new System.Windows.Forms.Button(); this.N = new System.Windows.Forms.Button();
@ -131,7 +131,6 @@
this.CompareBox.Size = new System.Drawing.Size(27, 20); this.CompareBox.Size = new System.Drawing.Size(27, 20);
this.CompareBox.TabIndex = 22; this.CompareBox.TabIndex = 22;
this.CompareBox.TextChanged += new System.EventHandler(this.CompareBox_TextChanged); this.CompareBox.TextChanged += new System.EventHandler(this.CompareBox_TextChanged);
this.CompareBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CompareBox_KeyPress);
// //
// ValueBox // ValueBox
// //
@ -143,7 +142,6 @@
this.ValueBox.Size = new System.Drawing.Size(27, 20); this.ValueBox.Size = new System.Drawing.Size(27, 20);
this.ValueBox.TabIndex = 23; this.ValueBox.TabIndex = 23;
this.ValueBox.TextChanged += new System.EventHandler(this.ValueBox_TextChanged); this.ValueBox.TextChanged += new System.EventHandler(this.ValueBox_TextChanged);
this.ValueBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ValueBox_KeyPress);
// //
// AddressBox // AddressBox
// //
@ -155,7 +153,6 @@
this.AddressBox.Size = new System.Drawing.Size(39, 20); this.AddressBox.Size = new System.Drawing.Size(39, 20);
this.AddressBox.TabIndex = 21; this.AddressBox.TabIndex = 21;
this.AddressBox.TextChanged += new System.EventHandler(this.AddressBox_TextChanged); this.AddressBox.TextChanged += new System.EventHandler(this.AddressBox_TextChanged);
this.AddressBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.AddressBox_KeyPress);
// //
// AddCheat // AddCheat
// //
@ -509,9 +506,9 @@
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox CompareBox; private HexTextBox CompareBox;
private System.Windows.Forms.TextBox ValueBox; private HexTextBox ValueBox;
private System.Windows.Forms.TextBox AddressBox; private HexTextBox AddressBox;
private System.Windows.Forms.Button AddCheat; private System.Windows.Forms.Button AddCheat;
private System.Windows.Forms.Panel ButtonPanel; private System.Windows.Forms.Panel ButtonPanel;
private System.Windows.Forms.Button L; private System.Windows.Forms.Button L;

View File

@ -57,19 +57,16 @@ namespace BizHawk.MultiClient
private void GameGenieCode_KeyPress(object sender, KeyPressEventArgs e) private void GameGenieCode_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b' || e.KeyChar == 22)
{
return;
}
//Make uppercase //Make uppercase
if (e.KeyChar >= 97 && e.KeyChar < 123) if (e.KeyChar >= 97 && e.KeyChar < 123)
e.KeyChar -= (char)32; e.KeyChar -= (char)32;
if (!(GameGenieTable.ContainsKey(e.KeyChar))) if (!(GameGenieTable.ContainsKey(e.KeyChar)))
{ {
if (!(e.KeyChar == (char)Keys.Back)) //Allow backspace if (!(e.KeyChar == (char)Keys.Back) || e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
{
e.Handled = true; e.Handled = true;
}
} }
else else
{ {
@ -233,53 +230,6 @@ namespace BizHawk.MultiClient
} }
} }
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar == (char)Keys.Back)) //Allow backspace
{
if (InputValidate.IsValidHexNumber(e.KeyChar))
{
Encoding.Checked = true;
}
else
e.Handled = true;
}
else
Encoding.Checked = true;
}
private void CompareBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar == (char)Keys.Back)) //Allow backspace
{
if (InputValidate.IsValidHexNumber(e.KeyChar))
{
Encoding.Checked = true;
}
else
e.Handled = true;
}
else
Encoding.Checked = true;
}
private void ValueBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(e.KeyChar == (char)Keys.Back)) //Allow backspace
{
if (InputValidate.IsValidHexNumber(e.KeyChar))
{
Encoding.Checked = true;
}
else
e.Handled = true;
}
else
Encoding.Checked = true;
}
private void AddressBox_TextChanged(object sender, EventArgs e) private void AddressBox_TextChanged(object sender, EventArgs e)
{ {
if (Encoding.Checked && AddressBox.Text.Length > 0) if (Encoding.Checked && AddressBox.Text.Length > 0)

View File

@ -881,22 +881,35 @@ namespace BizHawk.MultiClient
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e) private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b') return; if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
if (!InputValidate.IsValidHexNumber(e.KeyChar)) {
return;
}
else if (!InputValidate.IsValidHexNumber(e.KeyChar))
{
e.Handled = true; e.Handled = true;
}
} }
private void ValueBox_KeyPress(object sender, KeyPressEventArgs e) private void ValueBox_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b') return; if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
if (!InputValidate.IsValidHexNumber(e.KeyChar)) {
return;
}
else if (!InputValidate.IsValidHexNumber(e.KeyChar))
{
e.Handled = true; e.Handled = true;
}
} }
private void CheatListView_AfterLabelEdit(object sender, LabelEditEventArgs e) private void CheatListView_AfterLabelEdit(object sender, LabelEditEventArgs e)
{ {
if (e.Label == null) //If no change if (e.Label == null) //If no change
{
return; return;
}
string Str = e.Label; string Str = e.Label;
int index = e.Item; int index = e.Item;
Global.CheatList.cheatList[e.Item].name = Str; Global.CheatList.cheatList[e.Item].name = Str;
@ -1180,7 +1193,7 @@ namespace BizHawk.MultiClient
private void CompareBox_KeyPress(object sender, KeyPressEventArgs e) private void CompareBox_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b') if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
{ {
return; return;
} }

View File

@ -30,7 +30,7 @@
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RamPoke)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RamPoke));
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.AddressBox = new System.Windows.Forms.TextBox(); this.AddressBox = new HexTextBox();
this.DataTypeGroupBox = new System.Windows.Forms.GroupBox(); this.DataTypeGroupBox = new System.Windows.Forms.GroupBox();
this.HexRadio = new System.Windows.Forms.RadioButton(); this.HexRadio = new System.Windows.Forms.RadioButton();
this.UnsignedRadio = new System.Windows.Forms.RadioButton(); this.UnsignedRadio = new System.Windows.Forms.RadioButton();
@ -73,7 +73,6 @@
this.AddressBox.Size = new System.Drawing.Size(80, 20); this.AddressBox.Size = new System.Drawing.Size(80, 20);
this.AddressBox.TabIndex = 2; this.AddressBox.TabIndex = 2;
this.AddressBox.Text = "0000"; this.AddressBox.Text = "0000";
this.AddressBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.AddressBox_KeyPress);
this.AddressBox.Leave += new System.EventHandler(this.AddressBox_Leave); this.AddressBox.Leave += new System.EventHandler(this.AddressBox_Leave);
// //
// DataTypeGroupBox // DataTypeGroupBox
@ -321,7 +320,7 @@
#endregion #endregion
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox AddressBox; private HexTextBox AddressBox;
private System.Windows.Forms.GroupBox DataTypeGroupBox; private System.Windows.Forms.GroupBox DataTypeGroupBox;
private System.Windows.Forms.RadioButton SignedRadio; private System.Windows.Forms.RadioButton SignedRadio;
private System.Windows.Forms.RadioButton UnsignedRadio; private System.Windows.Forms.RadioButton UnsignedRadio;

View File

@ -319,14 +319,6 @@ namespace BizHawk.MultiClient
} }
} }
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b') return;
if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true;
}
private void ValueBox_KeyPress(object sender, KeyPressEventArgs e) private void ValueBox_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b') return; if (e.KeyChar == '\b') return;

View File

@ -125,7 +125,7 @@
this.CompareToBox = new System.Windows.Forms.GroupBox(); this.CompareToBox = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.NumberOfChangesBox = new System.Windows.Forms.TextBox(); this.NumberOfChangesBox = new System.Windows.Forms.TextBox();
this.SpecificAddressBox = new System.Windows.Forms.TextBox(); this.SpecificAddressBox = new HexTextBox();
this.SpecificValueBox = new System.Windows.Forms.TextBox(); this.SpecificValueBox = new System.Windows.Forms.TextBox();
this.NumberOfChangesRadio = new System.Windows.Forms.RadioButton(); this.NumberOfChangesRadio = new System.Windows.Forms.RadioButton();
this.SpecificAddressRadio = new System.Windows.Forms.RadioButton(); this.SpecificAddressRadio = new System.Windows.Forms.RadioButton();
@ -1039,7 +1039,6 @@
this.SpecificAddressBox.Size = new System.Drawing.Size(65, 20); this.SpecificAddressBox.Size = new System.Drawing.Size(65, 20);
this.SpecificAddressBox.TabIndex = 26; this.SpecificAddressBox.TabIndex = 26;
this.SpecificAddressBox.TextChanged += new System.EventHandler(this.SpecificAddressBox_TextChanged); this.SpecificAddressBox.TextChanged += new System.EventHandler(this.SpecificAddressBox_TextChanged);
this.SpecificAddressBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.SpecificAddressBox_KeyPress);
this.SpecificAddressBox.Leave += new System.EventHandler(this.SpecificAddressBox_Leave); this.SpecificAddressBox.Leave += new System.EventHandler(this.SpecificAddressBox_Leave);
// //
// SpecificValueBox // SpecificValueBox
@ -1320,7 +1319,7 @@
private System.Windows.Forms.RadioButton SpecificValueRadio; private System.Windows.Forms.RadioButton SpecificValueRadio;
private System.Windows.Forms.RadioButton PreviousValueRadio; private System.Windows.Forms.RadioButton PreviousValueRadio;
private System.Windows.Forms.TextBox NumberOfChangesBox; private System.Windows.Forms.TextBox NumberOfChangesBox;
private System.Windows.Forms.TextBox SpecificAddressBox; private HexTextBox SpecificAddressBox;
private System.Windows.Forms.TextBox SpecificValueBox; private System.Windows.Forms.TextBox SpecificValueBox;
private System.Windows.Forms.ToolStripSplitButton EndiantoolSplitButton; private System.Windows.Forms.ToolStripSplitButton EndiantoolSplitButton;
private System.Windows.Forms.ToolStripMenuItem bigEndianToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem bigEndianToolStripMenuItem;

View File

@ -2095,14 +2095,6 @@ namespace BizHawk.MultiClient
} }
} }
private void SpecificAddressBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b') return;
if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true;
}
private void NumberOfChangesBox_KeyPress(object sender, KeyPressEventArgs e) private void NumberOfChangesBox_KeyPress(object sender, KeyPressEventArgs e)
{ {
if (e.KeyChar == '\b') return; if (e.KeyChar == '\b') return;

View File

@ -31,7 +31,7 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RamWatchNewWatch)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RamWatchNewWatch));
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.AddressBox = new System.Windows.Forms.TextBox(); this.AddressBox = new HexTextBox();
this.NotesBox = new System.Windows.Forms.TextBox(); this.NotesBox = new System.Windows.Forms.TextBox();
this.DataTypeGroupBox = new System.Windows.Forms.GroupBox(); this.DataTypeGroupBox = new System.Windows.Forms.GroupBox();
this.HexRadio = new System.Windows.Forms.RadioButton(); this.HexRadio = new System.Windows.Forms.RadioButton();
@ -80,7 +80,6 @@
this.AddressBox.Size = new System.Drawing.Size(100, 20); this.AddressBox.Size = new System.Drawing.Size(100, 20);
this.AddressBox.TabIndex = 2; this.AddressBox.TabIndex = 2;
this.AddressBox.Text = "00000000"; this.AddressBox.Text = "00000000";
this.AddressBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.AddressBox_KeyPress);
this.AddressBox.Leave += new System.EventHandler(this.AddressBox_Leave); this.AddressBox.Leave += new System.EventHandler(this.AddressBox_Leave);
// //
// NotesBox // NotesBox
@ -293,7 +292,7 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox AddressBox; private HexTextBox AddressBox;
private System.Windows.Forms.TextBox NotesBox; private System.Windows.Forms.TextBox NotesBox;
private System.Windows.Forms.GroupBox DataTypeGroupBox; private System.Windows.Forms.GroupBox DataTypeGroupBox;
private System.Windows.Forms.RadioButton SignedRadio; private System.Windows.Forms.RadioButton SignedRadio;

View File

@ -114,19 +114,6 @@ namespace BizHawk.MultiClient
this.Close(); this.Close();
} }
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b' || e.KeyChar == 22)
{
return;
}
if (!InputValidate.IsValidHexNumber(e.KeyChar))
{
e.Handled = true;
}
}
private void AddressBox_Leave(object sender, EventArgs e) private void AddressBox_Leave(object sender, EventArgs e)
{ {
AddressBox.Text = AddressBox.Text.Replace(" ", ""); AddressBox.Text = AddressBox.Text.Replace(" ", "");