From: Jean-Philippe Bruyère Date: Fri, 9 Apr 2021 02:42:23 +0000 (+0200) Subject: label.Text locations check, event.Handled = true for mouse overrides in TextBox X-Git-Tag: v0.9.5-beta~35 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=1a2d73613006acc5d519bac9b86d8c0c79ae9d46;p=jp%2Fcrow.git label.Text locations check, event.Handled = true for mouse overrides in TextBox --- diff --git a/Crow/src/Widgets/Label.cs b/Crow/src/Widgets/Label.cs index 00788de4..f8574959 100644 --- a/Crow/src/Widgets/Label.cs +++ b/Crow/src/Widgets/Label.cs @@ -161,12 +161,26 @@ namespace Crow getLines (); textMeasureIsUpToDate = false; } + constraintsLocations(); NotifyValueChanged ("Text", Text); OnTextChanged (this, new TextChangeEventArgs (new TextChange (0, oldTextLength, _text))); RegisterForGraphicUpdate (); } } + void constraintsLocations () { + if (selectionStart.HasValue) { + CharLocation loc = CurrentLoc.Value; + int l = Math.Min (loc.Line, lines.Count - 1); + selectionStart = new CharLocation (l, Math.Min (loc.Column, lines[l].Length - 1)); + } + if (CurrentLoc.HasValue) { + CharLocation loc = CurrentLoc.Value; + int l = Math.Min (loc.Line, lines.Count - 1); + CurrentLoc = new CharLocation (l, Math.Min (loc.Column, lines[l].Length - 1)); + } + } + /// /// If 'true', linebreaks will be interpreted. If 'false', linebreaks are threated as unprintable /// unicode characters. Default value is 'False'. @@ -181,6 +195,7 @@ namespace Crow return; _multiline = value; getLines (); + constraintsLocations(); NotifyValueChangedAuto (_multiline); RegisterForGraphicUpdate(); } @@ -445,6 +460,7 @@ namespace Crow selRect.Width = selEnd.VisualCharXPosition - selStart.VisualCharXPosition; } + gr.SetSource (selBackground); gr.Rectangle (selRect); if (encodedBytes < 0) @@ -518,7 +534,7 @@ namespace Crow return true; } - void updateLocation (Context gr, int clientWidth, ref CharLocation? location) { + protected void updateLocation (Context gr, int clientWidth, ref CharLocation? location) { if (location == null) return; CharLocation loc = location.Value; diff --git a/Crow/src/Widgets/TextBox.cs b/Crow/src/Widgets/TextBox.cs index dddcdfb1..bf1678f4 100644 --- a/Crow/src/Widgets/TextBox.cs +++ b/Crow/src/Widgets/TextBox.cs @@ -133,17 +133,20 @@ namespace Crow } /// Process scrolling vertically, or if shift is down, vertically - public override void onMouseWheel (object sender, MouseWheelEventArgs e) { - base.onMouseWheel (sender, e); + public override void onMouseWheel (object sender, MouseWheelEventArgs e) { if (IFace.Shift) ScrollX += e.Delta * MouseWheelSpeed; else ScrollY -= e.Delta * MouseWheelSpeed; + + e.Handled = true; + base.onMouseWheel (sender, e); } - public override void onMouseMove (object sender, MouseMoveEventArgs e) { - base.onMouseMove (sender, e); - if (!HasFocus || !IFace.IsDown (MouseButton.Left)) - return; + public override void onMouseMove (object sender, MouseMoveEventArgs e) { + if (!HasFocus || !IFace.IsDown (MouseButton.Left)) { + base.onMouseMove (sender, e); + return; + } Rectangle cb = ClientRectangle; if (CurrentLoc.Value.VisualCharXPosition < scrollX) @@ -161,6 +164,8 @@ namespace Crow else if (CurrentLoc.Value.Line > lastLine) ScrollY = (int)(lineHeight * (CurrentLoc.Value.Line + 1)) - cb.Height; + e.Handled = true; + base.onMouseMove (sender, e); } #endregion public override void OnLayoutChanges (LayoutingType layoutType) {