summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Cory Forsstrom <cforsstrom18@gmail.com>2022-10-27 12:10:47 -0700
committerLibravatar Cory Forsstrom <cforsstrom18@gmail.com>2022-10-27 12:10:47 -0700
commitea4b3cd6aeb3c4dcb5113389c85f577fd3714682 (patch)
tree94314cdb6cea45251d669d26ac30b42856e97aee /native
parent2c103f8654943c773b6de3c70eb2927e92219422 (diff)
downloadiced-ea4b3cd6aeb3c4dcb5113389c85f577fd3714682.tar.gz
iced-ea4b3cd6aeb3c4dcb5113389c85f577fd3714682.tar.bz2
iced-ea4b3cd6aeb3c4dcb5113389c85f577fd3714682.zip
Fix text input padding
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/text_input.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs
index c2d25520..6ac4a2dd 100644
--- a/native/src/widget/text_input.rs
+++ b/native/src/widget/text_input.rs
@@ -350,15 +350,21 @@ where
{
let text_size = size.unwrap_or_else(|| renderer.default_size());
- let limits = limits
+ let text_limits = limits
.pad(padding)
.width(width)
.height(Length::Units(text_size));
+ let limits = limits.width(width).height(Length::Shrink);
+
+ let mut text = layout::Node::new(text_limits.resolve(Size::ZERO));
+
+ let padding = padding.constrain(text.size(), limits.max());
- let mut text = layout::Node::new(limits.resolve(Size::ZERO));
text.move_to(Point::new(padding.left.into(), padding.top.into()));
- layout::Node::with_children(text.size().pad(padding), vec![text])
+ let size = limits.pad(padding).resolve(text.size()).pad(padding);
+
+ layout::Node::with_children(size, vec![text])
}
/// Processes an [`Event`] and updates the [`State`] of a [`TextInput`]