git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commitf6eb0355521d3703a58db404c9a9a024657d26c8
parent45d1ba74d6
authorLucas Galante <[email protected]>
date2026-07-02 22:56
Aligned single-line TextBox caret vertical coordinate with text y alignment

 src/widget/input/text_box.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/widget/input/text_box.rs b/src/widget/input/text_box.rs
index ab88e01..d408e33 100644
--- a/src/widget/input/text_box.rs
+++ b/src/widget/input/text_box.rs
@@ -1022,7 +1022,8 @@ impl Element for TextBox {
                 if self.editing {
                     let cursor_x = self.base.x + 8.0 + (self.cursor_idx as f32 * char_width) - self.scroll_x;
                     if cursor_x >= self.base.x + 8.0 && cursor_x <= self.base.x + self.base.w - 8.0 {
-                        let cursor_y = self.base.y + top + (visual_h - caret_h) / 2.0;
+                        let text_y = crate::layout::align_text_y(self.base.y, self.base.h, self.font_size, top);
+                        let cursor_y = text_y + (self.font_size - caret_h) / 2.0;
                         quads.push((cursor_x, cursor_y, 1.5, caret_h, cursor_color));
                     }
                 }