Skip to content

Commit 665b944

Browse files
committed
fix(lineinput): caret isn't showed with empty text
1 parent 3953fe8 commit 665b944

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

SharpEngine.Core/Widget/LineInput.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ public override void Draw()
162162
var finalPosition = new Vec2(RealPosition.X - Size.X / 2 + 4, RealPosition.Y - textSize.Y / 2);
163163

164164
SERender.ScissorMode(
165-
(int)finalPosition.X,
166-
(int)finalPosition.Y,
167-
(int)Size.X - 8,
168-
(int)textSize.Y,
165+
finalPosition.X,
166+
finalPosition.Y,
167+
Size.X - 8,
168+
textSize.Y,
169169
InstructionSource.UI,
170170
ZLayer + 0.00002f,
171171
() =>
@@ -185,14 +185,17 @@ public override void Draw()
185185
}
186186

187187
if (Focused)
188+
{
189+
var potentielSize = Raylib.MeasureTextEx(finalFont.Value, "A", finalFontSize, 2);
188190
SERender.DrawRectangle(
189-
(int)(RealPosition.X - Size.X / 2 + 10 + textSize.X - (offset > 0 ? offset : 0)),
190-
(int)(RealPosition.Y - textSize.Y / 2 + 4),
191-
5,
192-
(int)textSize.Y - 8,
193-
Color.Black,
194-
InstructionSource.UI,
195-
ZLayer + 0.00003f
196-
);
191+
(RealPosition.X - Size.X / 2 + 10 + textSize.X - (offset > 0 ? offset : 0)),
192+
(RealPosition.Y - potentielSize.Y / 2 + 2),
193+
5,
194+
potentielSize.Y - 4,
195+
Color.Black,
196+
InstructionSource.UI,
197+
ZLayer + 0.00003f
198+
);
199+
}
197200
}
198201
}

0 commit comments

Comments
 (0)