summaryrefslogtreecommitdiffstats
path: root/core/src/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2019-11-14 06:48:12 +0100
committerLibravatar GitHub <noreply@github.com>2019-11-14 06:48:12 +0100
commitaf5ec4941270c832557994d9b4cc70ce5feac911 (patch)
tree7ea832e70007aeef958ac40b525783f590ff2d26 /core/src/widget
parenta16dab9cf2e27cb933cc91383ca79ba8e188c4c2 (diff)
parentbe5466a0a7ee6a16b5c07e61c9a22068ad8e127f (diff)
downloadiced-af5ec4941270c832557994d9b4cc70ce5feac911.tar.gz
iced-af5ec4941270c832557994d9b4cc70ce5feac911.tar.bz2
iced-af5ec4941270c832557994d9b4cc70ce5feac911.zip
Merge pull request #55 from hecrj/example/edit-todos
Edit and delete todos
Diffstat (limited to 'core/src/widget')
-rw-r--r--core/src/widget/button.rs8
-rw-r--r--core/src/widget/text_input.rs13
2 files changed, 21 insertions, 0 deletions
diff --git a/core/src/widget/button.rs b/core/src/widget/button.rs
index 9cf20071..e7961284 100644
--- a/core/src/widget/button.rs
+++ b/core/src/widget/button.rs
@@ -19,6 +19,8 @@ pub struct Button<'a, Message, Element> {
pub width: Length,
+ pub min_width: u32,
+
pub padding: u16,
pub background: Option<Background>,
@@ -52,6 +54,7 @@ impl<'a, Message, Element> Button<'a, Message, Element> {
content: content.into(),
on_press: None,
width: Length::Shrink,
+ min_width: 0,
padding: 0,
background: None,
border_radius: 0,
@@ -66,6 +69,11 @@ impl<'a, Message, Element> Button<'a, Message, Element> {
self
}
+ pub fn min_width(mut self, min_width: u32) -> Self {
+ self.min_width = min_width;
+ self
+ }
+
pub fn padding(mut self, padding: u16) -> Self {
self.padding = padding;
self
diff --git a/core/src/widget/text_input.rs b/core/src/widget/text_input.rs
index 9c7f4bc8..450a7cae 100644
--- a/core/src/widget/text_input.rs
+++ b/core/src/widget/text_input.rs
@@ -91,6 +91,15 @@ impl State {
Self::default()
}
+ pub fn focused() -> Self {
+ use std::usize;
+
+ Self {
+ is_focused: true,
+ cursor_position: usize::MAX,
+ }
+ }
+
pub fn move_cursor_right(&mut self, value: &Value) {
let current = self.cursor_position(value);
@@ -107,6 +116,10 @@ impl State {
}
}
+ pub fn move_cursor_to_end(&mut self, value: &Value) {
+ self.cursor_position = value.len();
+ }
+
pub fn cursor_position(&self, value: &Value) -> usize {
self.cursor_position.min(value.len())
}