Lua - forms.textbox() add field to optionally set the textbox to signed, unsigned, or hex values
This commit is contained in:
parent
3f81bc9cdb
commit
9da0cd3553
|
@ -335,6 +335,9 @@
|
||||||
<Compile Include="tools\LuaButton.cs">
|
<Compile Include="tools\LuaButton.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="tools\LuaTextBox.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="tools\LuaWinform.cs">
|
<Compile Include="tools\LuaWinform.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -1798,7 +1798,7 @@ namespace BizHawk.MultiClient
|
||||||
return (int)label.Handle;
|
return (int)label.Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int forms_textbox(object form_handle, object caption = null, object width = null, object height = null, object X = null, object Y = null)
|
public int forms_textbox(object form_handle, object caption = null, object width = null, object height = null, object boxtype = null, object X = null, object Y = null)
|
||||||
{
|
{
|
||||||
LuaWinform form = GetForm(form_handle);
|
LuaWinform form = GetForm(form_handle);
|
||||||
if (form == null)
|
if (form == null)
|
||||||
|
@ -1806,10 +1806,30 @@ namespace BizHawk.MultiClient
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBox textbox = new TextBox();
|
LuaTextBox textbox = new LuaTextBox();
|
||||||
SetText(textbox, caption);
|
SetText(textbox, caption);
|
||||||
SetLocation(textbox, X, Y);
|
SetLocation(textbox, X, Y);
|
||||||
SetSize(textbox, X, Y);
|
SetSize(textbox, X, Y);
|
||||||
|
if (boxtype != null)
|
||||||
|
{
|
||||||
|
switch (boxtype.ToString().ToUpper())
|
||||||
|
{
|
||||||
|
case "HEX":
|
||||||
|
case "HEXADECIMAL":
|
||||||
|
textbox.SetType(BoxType.HEX);
|
||||||
|
break;
|
||||||
|
case "UNSIGNED":
|
||||||
|
case "UINT":
|
||||||
|
textbox.SetType(BoxType.UNSIGNED);
|
||||||
|
break;
|
||||||
|
case "NUMBER":
|
||||||
|
case "NUM":
|
||||||
|
case "SIGNED":
|
||||||
|
case "INT":
|
||||||
|
textbox.SetType(BoxType.SIGNED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
form.Controls.Add(textbox);
|
form.Controls.Add(textbox);
|
||||||
return (int)textbox.Handle;
|
return (int)textbox.Handle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace BizHawk.MultiClient.tools
|
||||||
|
{
|
||||||
|
enum BoxType { ALL, SIGNED, UNSIGNED, HEX };
|
||||||
|
class LuaTextBox : TextBox
|
||||||
|
{
|
||||||
|
private BoxType boxType = BoxType.ALL;
|
||||||
|
|
||||||
|
public void SetType(BoxType type)
|
||||||
|
{
|
||||||
|
boxType = type;
|
||||||
|
if (type != BoxType.ALL)
|
||||||
|
{
|
||||||
|
CharacterCasing = CharacterCasing.Upper;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CharacterCasing = CharacterCasing.Normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnKeyPress(KeyPressEventArgs e)
|
||||||
|
{
|
||||||
|
SpecificValueBox_KeyPress(this, e);
|
||||||
|
base.OnKeyPress(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SpecificValueBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.KeyChar == '\b') return;
|
||||||
|
|
||||||
|
switch (boxType)
|
||||||
|
{
|
||||||
|
case BoxType.UNSIGNED:
|
||||||
|
if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
|
||||||
|
e.Handled = true;
|
||||||
|
break;
|
||||||
|
case BoxType.SIGNED:
|
||||||
|
if (!InputValidate.IsValidSignedNumber(e.KeyChar))
|
||||||
|
e.Handled = true;
|
||||||
|
break;
|
||||||
|
case BoxType.HEX:
|
||||||
|
if (!InputValidate.IsValidHexNumber(e.KeyChar))
|
||||||
|
e.Handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue