Use seconds helper in tooltip example
This commit is contained in:
parent
cbc311ed9e
commit
defd59584f
1 changed files with 3 additions and 5 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
use iced::Element;
|
use iced::Element;
|
||||||
|
use iced::alignment;
|
||||||
|
use iced::time::seconds;
|
||||||
use iced::widget::tooltip::Position;
|
use iced::widget::tooltip::Position;
|
||||||
use iced::widget::{button, center, checkbox, column, container, tooltip};
|
use iced::widget::{button, center, checkbox, column, container, tooltip};
|
||||||
use iced::{alignment, time::Duration};
|
|
||||||
|
|
||||||
pub fn main() -> iced::Result {
|
pub fn main() -> iced::Result {
|
||||||
iced::run(Tooltip::update, Tooltip::view)
|
iced::run(Tooltip::update, Tooltip::view)
|
||||||
|
|
@ -40,9 +41,6 @@ impl Tooltip {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(&self) -> Element<'_, Message> {
|
fn view(&self) -> Element<'_, Message> {
|
||||||
let delay =
|
|
||||||
Duration::from_millis(if self.is_immediate { 0 } else { 2000 });
|
|
||||||
|
|
||||||
let tooltip = tooltip(
|
let tooltip = tooltip(
|
||||||
button("Press to change position")
|
button("Press to change position")
|
||||||
.on_press(Message::ChangePosition),
|
.on_press(Message::ChangePosition),
|
||||||
|
|
@ -50,7 +48,7 @@ impl Tooltip {
|
||||||
self.position,
|
self.position,
|
||||||
)
|
)
|
||||||
.gap(10)
|
.gap(10)
|
||||||
.delay(delay)
|
.delay(seconds(if self.is_immediate { 0 } else { 2 }))
|
||||||
.style(container::rounded_box);
|
.style(container::rounded_box);
|
||||||
|
|
||||||
let checkbox = checkbox(self.is_immediate)
|
let checkbox = checkbox(self.is_immediate)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue