aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjp <jp_bruyere@hotmail.com>2016-03-15 14:10:54 +0100
committerjp <jp_bruyere@hotmail.com>2016-03-15 14:10:54 +0100
commit7d84e81ebdc0bf89b5aa89cef2375c4acae7b37e (patch)
tree3212e1f2672b5864483f77f716fd831d7bd0e7cc /src/GraphicObjects
parent97e0683c77461e7f13ab40ff9bc6f8a56c7a9d7e (diff)
keypress event
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/GraphicObject.cs4
-rw-r--r--src/GraphicObjects/TextBox.cs73
2 files changed, 21 insertions, 56 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index b61ecb32..c526e909 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -156,6 +156,7 @@ namespace Crow
public event EventHandler<MouseMoveEventArgs> MouseLeave;
public event EventHandler<KeyboardKeyEventArgs> KeyDown;
public event EventHandler<KeyboardKeyEventArgs> KeyUp;
+ public event EventHandler<KeyPressEventArgs> KeyPress;
public event EventHandler Focused;
public event EventHandler Unfocused;
public event EventHandler<LayoutingEventArgs> LayoutChanged;
@@ -939,6 +940,9 @@ namespace Crow
public virtual void onKeyDown(object sender, KeyboardKeyEventArgs e){
KeyDown.Raise (sender, e);
}
+ public virtual void onKeyPress(object sender, KeyPressEventArgs e){
+ KeyPress.Raise (sender, e);
+ }
#endregion
#region Mouse handling
diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs
index 14cc1830..d3b8319c 100644
--- a/src/GraphicObjects/TextBox.cs
+++ b/src/GraphicObjects/TextBox.cs
@@ -72,7 +72,6 @@ namespace Crow
public override void onKeyDown (object sender, KeyboardKeyEventArgs e)
{
base.onKeyDown (sender, e);
-
Key key = e.Key;
switch (key)
@@ -80,9 +79,9 @@ namespace Crow
case Key.Back:
if (!selectionIsEmpty)
{
-// Text = Text.Remove(selectionStart, selectionEnd - selectionStart);
-// selReleasePos = -1;
-// currentCol = selBeginPos;
+ // Text = Text.Remove(selectionStart, selectionEnd - selectionStart);
+ // selReleasePos = -1;
+ // currentCol = selBeginPos;
}
else
this.DeleteChar();
@@ -141,62 +140,24 @@ namespace Crow
break;
case Key.RWin:
break;
- case Key.Tab:
- this.Insert("\t");
- break;
- case Key.KeypadDecimal:
- this.Insert (".");
- break;
- case Key.Space:
- this.Insert(" ");
- break;
- case Key.KeypadDivide:
- case Key.Slash:
- this.Insert("/");
- break;
- case Key.KeypadMultiply:
- this.Insert("*");
- break;
- case Key.KeypadMinus:
- case Key.Minus:
- this.Insert("-");
- break;
- case Key.KeypadPlus:
- case Key.Plus:
- this.Insert("+");
- break;
- case Key.ShiftLeft:
- case Key.ShiftRight:
- case Key.AltLeft:
- case Key.AltRight:
- break;
- case Key.Semicolon:
- this.Insert(";");
- break;
default:
- if (!selectionIsEmpty)
- {
-// Text = Text.Remove(selectionStart, selectionEnd - selectionStart);
-// currentCol = selBeginPos;
- }
-
- string k = "?";
- if ((char)key >= 67 && (char)key <= 76)
- k = ((int)key - 67).ToString();
- else if ((char)key >= 109 && (char)key <= 118)
- k = ((int)key - 109).ToString();
- else if (e.Shift)
- k = key.ToString();
- else
- k = key.ToString().ToLower();
+ break;
+ }
+ if (Width < 0)
+ RegisterForLayouting (LayoutingType.Width);
+ if (Height < 0)
+ RegisterForLayouting (LayoutingType.Height);
+ RegisterForGraphicUpdate();
+ }
+ public override void onKeyPress (object sender, KeyPressEventArgs e)
+ {
+ base.onKeyPress (sender, e);
- this.Insert (k);
+ this.Insert (e.KeyChar.ToString());
- SelRelease = -1;
- SelBegin = new Point(CurrentColumn, SelBegin.Y);
+ SelRelease = -1;
+ SelBegin = new Point(CurrentColumn, SelBegin.Y);
- break;
- }
if (Width < 0)
RegisterForLayouting (LayoutingType.Width);
if (Height < 0)