aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-04-09 04:42:23 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-04-09 04:42:23 +0200
commit1a2d73613006acc5d519bac9b86d8c0c79ae9d46 (patch)
tree1afeb85f1b747290d6572e929be9c9b73be76238
parent8c0f9d6b02eac97b7a45780f82f5683771745cf0 (diff)
label.Text locations check, event.Handled = true for mouse overrides in TextBox
-rw-r--r--Crow/src/Widgets/Label.cs18
-rw-r--r--Crow/src/Widgets/TextBox.cs17
2 files changed, 28 insertions, 7 deletions
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));
+ }
+ }
+
/// <summary>
/// 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
}
/// <summary> Process scrolling vertically, or if shift is down, vertically </summary>
- 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) {