- fixed crash when text is pasted in numeric textboxes

- made CTRL+X, XTRL+C and CTRL+V work for numeric textboxes
- fixed Edit Selection button for sector tags in Find & Replace
This commit is contained in:
codeimp 2009-01-27 19:03:20 +00:00
parent 9ab807a8d9
commit 18a9cc0803
3 changed files with 55 additions and 2 deletions

View file

@ -124,7 +124,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
public override void ObjectSelected(FindReplaceObject[] selection)
{
if(selection.Length == 1)
{
ZoomToSelection(selection);
General.Interface.ShowSectorInfo(selection[0].Sector);
}
else
General.Interface.HideInfo();
@ -143,6 +146,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Sector> sectors = new List<Sector>(selection.Length);
foreach(FindReplaceObject o in selection) sectors.Add(o.Sector);
General.Interface.ShowEditSectors(sectors);
}
#endregion
}

View file

@ -37,13 +37,14 @@ namespace CodeImp.DoomBuilder.Controls
// Variables
private List<GeneralizedCategory> generalizedcategories;
private bool controlpressed = false;
// Constants
private const string NUMBER_SEPERATOR = "\t";
// Properties
public bool Empty { get { return (number.Text.Length == 0); } set { if(value) number.Text = ""; } }
public int Value { get { if(number.Text.Length > 0) return int.Parse(number.Text); else return 0; } set { number.Text = value.ToString(); } }
public int Value { get { return GetValue(); } set { number.Text = value.ToString(); } }
public List<GeneralizedCategory> GeneralizedCategories { get { return generalizedcategories; } set { generalizedcategories = value; } }
// Constructor
@ -53,6 +54,23 @@ namespace CodeImp.DoomBuilder.Controls
InitializeComponent();
}
// This returns the numeric value
public int GetValue()
{
int val = 0;
if(number.Text.Length > 0)
{
try
{
val = Convert.ToInt32(number.Text);
}
catch(Exception e) { }
}
return val;
}
// This clears all information
public void ClearInfo()
{
@ -200,6 +218,11 @@ namespace CodeImp.DoomBuilder.Controls
// Keys pressed in number box
private void number_KeyDown(object sender, KeyEventArgs e)
{
controlpressed = e.Control;
// Allow CTRL+X, CTRL+C and CTRL+V
if(controlpressed && ((e.KeyCode == Keys.X) || (e.KeyCode == Keys.C) || (e.KeyCode == Keys.V))) return;
// Not numeric or control key?
if(((e.KeyValue < 48) || (e.KeyValue > 57)) &&
(e.KeyCode != Keys.Back) && (e.KeyCode != Keys.Left) &&
@ -213,6 +236,9 @@ namespace CodeImp.DoomBuilder.Controls
// Keys pressed in number box
private void number_KeyPress(object sender, KeyPressEventArgs e)
{
// Allow CTRL+X, CTRL+C and CTRL+V
if(controlpressed && ((e.KeyChar == '\u0018') || (e.KeyChar == '\u0003') || (e.KeyChar == '\u0016'))) return;
// Not numeric or control key?
if(((e.KeyChar < 48) || (e.KeyChar > 57)) && (e.KeyChar != 8))
{

View file

@ -42,7 +42,8 @@ namespace CodeImp.DoomBuilder.Controls
private bool allownegative = false; // Allow negative numbers
private bool allowrelative = false; // Allow ++ and -- prefix for relative changes
private bool controlpressed = false;
#endregion
#region ================== Properties
@ -64,6 +65,20 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Methods
// Key pressed
protected override void OnKeyDown(KeyEventArgs e)
{
controlpressed = e.Control;
base.OnKeyDown(e);
}
// Key released
protected override void OnKeyUp(KeyEventArgs e)
{
controlpressed = e.Control;
base.OnKeyUp(e);
}
// When a key is pressed
protected override void OnKeyPress(KeyPressEventArgs e)
{
@ -77,6 +92,7 @@ namespace CodeImp.DoomBuilder.Controls
// Determine allowed chars
if(allownegative) allowedchars += "-";
if(allowrelative) allowedchars += "+-";
if(controlpressed) allowedchars += "\u0018\u0003\u0016";
// Check if key is not allowed
if(allowedchars.IndexOf(e.KeyChar) == -1)