From 7539e6d44cdcf3746ec9bd6454659123fdd18370 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 30 Jan 2025 10:54:02 +0800 Subject: [PATCH] input: Fix Input to vertical center the mask chars. (#590) Close #467 Windows: image macOS: image --- crates/ui/src/input/element.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/ui/src/input/element.rs b/crates/ui/src/input/element.rs index e35716e0..baf78cec 100644 --- a/crates/ui/src/input/element.rs +++ b/crates/ui/src/input/element.rs @@ -504,6 +504,14 @@ impl Element for TextElement { let origin = bounds.origin; let mut offset_y = px(0.); + if self.input.read(cx).masked { + // Move down offset for vertical centering the ***** + if cfg!(target_os = "macos") { + offset_y = px(3.); + } else { + offset_y = px(2.5); + } + } for line in prepaint.lines.iter() { let p = point(origin.x, origin.y + offset_y); _ = line.paint(p, line_height, window, cx);