Revert tooltip delay to Duration::ZERO
This commit is contained in:
parent
b02db5e6f8
commit
2ac62f7512
2 changed files with 9 additions and 12 deletions
|
|
@ -11,13 +11,13 @@ pub fn main() -> iced::Result {
|
|||
#[derive(Default)]
|
||||
struct Tooltip {
|
||||
position: Position,
|
||||
is_immediate: bool,
|
||||
delay: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
ChangePosition,
|
||||
ToggleImmediate(bool),
|
||||
ToggleDelay(bool),
|
||||
}
|
||||
|
||||
impl Tooltip {
|
||||
|
|
@ -34,8 +34,8 @@ impl Tooltip {
|
|||
|
||||
self.position = position;
|
||||
}
|
||||
Message::ToggleImmediate(is_immediate) => {
|
||||
self.is_immediate = is_immediate;
|
||||
Message::ToggleDelay(is_immediate) => {
|
||||
self.delay = is_immediate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,12 +48,12 @@ impl Tooltip {
|
|||
self.position,
|
||||
)
|
||||
.gap(10)
|
||||
.delay(seconds(if self.is_immediate { 0 } else { 2 }))
|
||||
.delay(seconds(if self.delay { 1 } else { 0 }))
|
||||
.style(container::rounded_box);
|
||||
|
||||
let checkbox = checkbox(self.is_immediate)
|
||||
.label("Show immediately")
|
||||
.on_toggle(Message::ToggleImmediate);
|
||||
let checkbox = checkbox(self.delay)
|
||||
.label("Delay")
|
||||
.on_toggle(Message::ToggleDelay);
|
||||
|
||||
center(
|
||||
column![tooltip, checkbox]
|
||||
|
|
|
|||
|
|
@ -88,9 +88,6 @@ where
|
|||
/// The default padding of a [`Tooltip`] drawn by this renderer.
|
||||
const DEFAULT_PADDING: f32 = 5.0;
|
||||
|
||||
/// The default delay before a [`Tooltip`] is shown.
|
||||
const DEFAULT_DELAY: Duration = Duration::from_secs(2);
|
||||
|
||||
/// Creates a new [`Tooltip`].
|
||||
///
|
||||
/// [`Tooltip`]: struct.Tooltip.html
|
||||
|
|
@ -106,7 +103,7 @@ where
|
|||
gap: 0.0,
|
||||
padding: Self::DEFAULT_PADDING,
|
||||
snap_within_viewport: true,
|
||||
delay: Self::DEFAULT_DELAY,
|
||||
delay: Duration::ZERO,
|
||||
class: Theme::default(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue