aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/TextBox.cs
diff options
context:
space:
mode:
authorjp <jp_bruyere@hotmail.com>2016-04-04 00:24:02 +0200
committerjp <jp_bruyere@hotmail.com>2016-04-04 00:24:02 +0200
commit76fe2b4376ce36adbbf5e16b465036ba923b5555 (patch)
tree73a45d90a7860b502aa4a7d173297a881bb12fef /src/GraphicObjects/TextBox.cs
parent46214325e9cb0bc1914db95301555d60a536944c (diff)
add textbox text facilities and clipboard
Diffstat (limited to 'src/GraphicObjects/TextBox.cs')
-rw-r--r--src/GraphicObjects/TextBox.cs109
1 files changed, 78 insertions, 31 deletions
diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs
index 08ec1f69..a042198b 100644
--- a/src/GraphicObjects/TextBox.cs
+++ b/src/GraphicObjects/TextBox.cs
@@ -11,6 +11,7 @@ using System.Runtime.InteropServices;
namespace Crow
{
+ [DefaultStyle("#Crow.Styles.TextBox.style")]
public class TextBox : Label
{
#region CTOR
@@ -37,22 +38,6 @@ namespace Crow
RegisterForGraphicUpdate();
}
}
- [XmlAttributeAttribute()][DefaultValue(true)]
- public override bool Focusable
- {
- get { return base.Focusable; }
- set { base.Focusable = value; }
- }
- [XmlAttributeAttribute()][DefaultValue("White")]
- public override Fill Background {
- get { return base.Background; }
- set { base.Background = value; }
- }
- [XmlAttributeAttribute()][DefaultValue("Black")]
- public override Fill Foreground {
- get { return base.Foreground; }
- set { base.Foreground = value; }
- }
protected override void onDraw (Context gr)
{
@@ -78,24 +63,21 @@ namespace Crow
switch (key)
{
case Key.Back:
- if (!selectionIsEmpty)
- {
- // Text = Text.Remove(selectionStart, selectionEnd - selectionStart);
- // selReleasePos = -1;
- // currentCol = selBeginPos;
- }
- else
- this.DeleteChar();
+ this.DeleteChar();
break;
case Key.Clear:
break;
case Key.Delete:
if (selectionIsEmpty)
CurrentColumn++;
+ else if (e.Shift)
+ Interface.CurrentInterface.Clipboard = this.SelectedText;
this.DeleteChar ();
break;
case Key.Enter:
case Key.KeypadEnter:
+ if (!selectionIsEmpty)
+ this.DeleteChar ();
if (Multiline)
this.InsertLineBreak ();
else
@@ -107,35 +89,100 @@ namespace Crow
SelRelease = -1;
break;
case Key.Home:
- //TODO
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point (CurrentColumn, CurrentLine);
+ if (e.Control)
+ CurrentLine = 0;
+ CurrentColumn = 0;
+ SelRelease = new Point (CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
if (e.Control)
CurrentLine = 0;
CurrentColumn = 0;
break;
case Key.End:
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point (CurrentColumn, CurrentLine);
+ if (e.Control)
+ CurrentLine = int.MaxValue;
+ CurrentColumn = int.MaxValue;
+ SelRelease = new Point (CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
if (e.Control)
CurrentLine = int.MaxValue;
CurrentColumn = int.MaxValue;
break;
case Key.Insert:
+ if (e.Shift)
+ this.Insert (Interface.CurrentInterface.Clipboard);
break;
- case Key.Left:
- CurrentColumn--;
+ case Key.Left:
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point(CurrentColumn, CurrentLine);
+ if (e.Control)
+ GotoWordStart ();
+ else
+ CurrentColumn--;
+ SelRelease = new Point(CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
+ if (e.Control)
+ GotoWordStart ();
+ else
+ CurrentColumn--;
break;
- case Key.Right:
- CurrentColumn++;
+ case Key.Right:
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point(CurrentColumn, CurrentLine);
+ if (e.Control)
+ GotoWordEnd ();
+ else
+ CurrentColumn++;
+ SelRelease = new Point(CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
+ if (e.Control)
+ GotoWordEnd ();
+ else
+ CurrentColumn++;
break;
case Key.Up:
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point(CurrentColumn, CurrentLine);
+ CurrentLine--;
+ SelRelease = new Point(CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
CurrentLine--;
break;
case Key.Down:
- CurrentLine++;
+ if (e.Shift) {
+ if (selectionIsEmpty)
+ SelBegin = new Point(CurrentColumn, CurrentLine);
+ CurrentLine++;
+ SelRelease = new Point(CurrentColumn, CurrentLine);
+ break;
+ }
+ SelRelease = -1;
+ CurrentLine++;
break;
case Key.Menu:
break;
case Key.NumLock:
break;
- case Key.PageDown:
+ case Key.PageDown:
break;
case Key.PageUp:
break;