}
if (forceTextCursor) {
- if (FocusedWidget is Label lab && lab.SelectionIsEmpty) {
- Rectangle c = lab.DrawCursor (ctx);
- if (textCursor != null && c != textCursor.Value)
- RegisterClip (textCursor.Value);
- textCursor = c;
- surf.Flush ();
+ if (FocusedWidget is Label lab && lab.SelectionIsEmpty) {
+ if (lab.DrawCursor (ctx, out Rectangle c)) {
+ if (textCursor != null && c != textCursor.Value)
+ RegisterClip (textCursor.Value);
+ textCursor = c;
+ surf.Flush ();
+ } else if (textCursor != null)
+ RegisterClip (textCursor.Value);
}
blinkingCursor.Restart ();
forceTextCursor = false;
blinkingCursor.Restart ();
} else if (FocusedWidget is Label lab && lab.SelectionIsEmpty) {
if (blinkingCursor.ElapsedMilliseconds > TEXT_CURSOR_BLINK_FREQUENCY) {
- textCursor = lab.DrawCursor (ctx);
- surf.Flush ();
- blinkingCursor.Restart ();
+ if (lab.DrawCursor (ctx, out Rectangle c)) {
+ textCursor = c;
+ surf.Flush ();
+ blinkingCursor.Restart ();
+ }
}
}
public Point MousePosition { get; set; } = default;
public bool IsDown (MouseButton button) => Glfw3.GetMouseButton (hWin, button) != InputAction.Release;
- Cursor createCursor (MouseCursor mc)
- {
- const int minimumSize = 24;
- if (!XCursor.Cursors.ContainsKey (mc)) {
- XCursor.Cursors[mc] = XCursorFile.Load (this, $"#Crow.Cursors.{mc}").Cursors.First (cu => cu.Width >= minimumSize);
- }
- XCursor c = XCursor.Cursors [mc];
- return new CustomCursor (c.Width, c.Height, c.data, c.Xhot, c.Yhot);
- }
-
-
public MouseCursor MouseCursor {
get => cursor;
set {
}
RectangleD? textCursor = null;
- internal Rectangle DrawCursor (Context ctx) {
+ internal bool DrawCursor (Context ctx, out Rectangle rect) {
if (!currentLoc.Value.HasVisualX) {
ctx.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
ctx.SetFontSize (Font.Size);
updateLocation (ctx, ClientRectangle.Width, ref currentLoc);
textCursor = null;
}
+
//if (textCursor == null) {
Rectangle cb = ClientRectangle;
- int lineHeight = (int)(fe.Ascent + fe.Descent);
- textCursor = new RectangleD (currentLoc.Value.VisualCharXPosition + cb.X + Slot.X,
- cb.Y + Slot.Y + currentLoc.Value.Line * lineHeight, 1.0, lineHeight);
+ if (currentLoc.Value.VisualCharXPosition > cb.Width) {
+ rect = default;
+ return false;
+ }
+ int lineHeight = (int)(fe.Ascent + fe.Descent);
+ textCursor = new RectangleD (currentLoc.Value.VisualCharXPosition + cb.X + Slot.X,
+ cb.Y + Slot.Y + currentLoc.Value.Line * lineHeight, 1.0, lineHeight);
//}
Rectangle c = ScreenCoordinates (textCursor.Value);
ctx.ResetClip ();
ctx.MoveTo (0.5 + c.X, c.Y);
ctx.LineTo (0.5 + c.X, c.Bottom);
ctx.Stroke ();
- return c;
+ rect = c;
+ return true;
}
}