-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating typed_input (a text input but sending message only when it i…
…s valid for the given type) Adding suport for dots in number input
- Loading branch information
Showing
8 changed files
with
454 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "typed_input" | ||
version = "0.1.0" | ||
authors = ["Ultraxime <[email protected]>"] | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
iced_aw = { workspace = true, features = [ | ||
"typed_input", | ||
"icons", | ||
] } | ||
|
||
iced.workspace=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use iced::{ | ||
widget::{Container, Row, Text}, | ||
Alignment, Element, Length, | ||
}; | ||
use iced_aw::widgets::typed_input; | ||
|
||
#[derive(Default, Debug)] | ||
pub struct TypedInputDemo { | ||
value: f32, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum Message { | ||
TypedInpChanged(f32), | ||
} | ||
|
||
fn main() -> iced::Result { | ||
iced::application( | ||
"Typed Input example", | ||
TypedInputDemo::update, | ||
TypedInputDemo::view, | ||
) | ||
.window_size(iced::Size { | ||
width: 250.0, | ||
height: 200.0, | ||
}) | ||
.font(iced_aw::BOOTSTRAP_FONT_BYTES) | ||
.run() | ||
} | ||
|
||
impl TypedInputDemo { | ||
fn update(&mut self, message: self::Message) { | ||
let Message::TypedInpChanged(val) = message; | ||
println!("Value changed to {:?}", val); | ||
self.value = val; | ||
} | ||
|
||
fn view(&self) -> Element<Message> { | ||
let lb_minute = Text::new("Typed Input:"); | ||
let txt_minute = typed_input::TypedInput::new(self.value, Message::TypedInpChanged); | ||
|
||
Container::new( | ||
Row::new() | ||
.spacing(10) | ||
.align_items(Alignment::Center) | ||
.push(lb_minute) | ||
.push(txt_minute), | ||
) | ||
.width(Length::Fill) | ||
.height(Length::Fill) | ||
.center_x(Length::Fill) | ||
.center_y(Length::Fill) | ||
.into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.