Skip to content

Commit

Permalink
Merge pull request iced-rs#2143 from iced-rs/fix/tooltip-layout-inval…
Browse files Browse the repository at this point in the history
…idation

Invalidate layout when `Tooltip` changes `overlay`
  • Loading branch information
hecrj authored Nov 21, 2023
2 parents 879039a + f67387f commit 100d15f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion widget/src/tooltip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,19 @@ where
) -> event::Status {
let state = tree.state.downcast_mut::<State>();

let was_idle = *state == State::Idle;

*state = cursor
.position_over(layout.bounds())
.map(|cursor_position| State::Hovered { cursor_position })
.unwrap_or_default();

let is_idle = *state == State::Idle;

if was_idle != is_idle {
shell.invalidate_layout();
}

self.content.as_widget_mut().on_event(
&mut tree.children[0],
event,
Expand Down Expand Up @@ -289,7 +297,7 @@ pub enum Position {
Right,
}

#[derive(Debug, Clone, Copy, Default)]
#[derive(Debug, Clone, Copy, PartialEq, Default)]
enum State {
#[default]
Idle,
Expand Down

0 comments on commit 100d15f

Please sign in to comment.