From: jpbruyere Date: Fri, 5 Feb 2016 17:36:22 +0000 (+0100) Subject: Textbox and Label: insert linebreak, update size if Fit X-Git-Tag: 0.3~47 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=759f4f39e3fdde1f9ed8b620af51e05d052d8964;p=jp%2Fcrow.git Textbox and Label: insert linebreak, update size if Fit --- diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index ee7dd045..d8d214c7 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -271,7 +271,17 @@ namespace Crow CurrentColumn += str.Length; NotifyValueChanged ("Text", Text); } - + /// + /// Insert a line break. + /// + protected void InsertLineBreak() + { + lines.Insert(CurrentLine + 1, lines[CurrentLine].Substring(CurrentColumn)); + lines [CurrentLine] = lines [CurrentLine].Substring (0, CurrentColumn); + CurrentLine++; + CurrentColumn = 0; + NotifyValueChanged ("Text", Text); + } #region GraphicObject overrides [XmlAttributeAttribute()][DefaultValue(-1)] public override int Width { diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs index d9003b61..143d148f 100644 --- a/src/GraphicObjects/TextBox.cs +++ b/src/GraphicObjects/TextBox.cs @@ -97,7 +97,10 @@ namespace Crow break; case Key.Enter: case Key.KeypadEnter: - OnTextChanged(this,new TextChangeEventArgs(Text)); + if (Multiline) + this.InsertLineBreak (); + else + OnTextChanged(this,new TextChangeEventArgs(Text)); break; case Key.Escape: Text = ""; @@ -195,6 +198,10 @@ namespace Crow break; } + if (Width < 0) + RegisterForLayouting ((int)LayoutingType.Width); + if (Height < 0) + RegisterForLayouting ((int)LayoutingType.Height); registerForGraphicUpdate(); } #endregion