Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly pass the HAS_ACTIVE state up #148

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/widget/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ impl Pod {
}
};
if recurse {
// This clears the has_active state. Pod needs to clear this state since merge up can
// only set flags.
// This needs to happen before the `event` call, as that will also set our `HAS_ACTIVE`
// flag if any of our children were active
self.state.flags.set(
PodFlags::HAS_ACTIVE,
self.state.flags.contains(PodFlags::IS_ACTIVE),
);
let mut inner_cx = EventCx {
cx_state: cx.cx_state,
widget_state: &mut self.state,
Expand All @@ -294,12 +302,6 @@ impl Pod {
.event(&mut inner_cx, modified_event.as_ref().unwrap_or(event));
cx.is_handled |= inner_cx.is_handled;

// This clears the has_active state. Pod needs to clear this state since merge up can
// only set flags.
self.state.flags.set(
PodFlags::HAS_ACTIVE,
self.state.flags.contains(PodFlags::IS_ACTIVE),
);
cx.widget_state.merge_up(&mut self.state);
}
}
Expand Down Expand Up @@ -545,6 +547,7 @@ impl Pod {
/// is dragged away.
///
/// [`set_active`]: EventCx::set_active
// TODO: Determine why this is the same as [Self::has_active]
pub fn is_active(&self) -> bool {
self.state.flags.contains(PodFlags::HAS_ACTIVE)
}
Expand Down