Skip to content

Commit

Permalink
Ability for a view to resign from active state (#481)
Browse files Browse the repository at this point in the history
Fixes #470 - "No way to resign `active`"
  • Loading branch information
timboudreau committed May 30, 2024
1 parent fa49640 commit 1674b04
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ impl ViewId {
self.add_update_message(UpdateMessage::Active(*self));
}

pub fn clear_active(&self) {
self.add_update_message(UpdateMessage::ClearActive(*self));
}

pub fn inspect(&self) {
self.add_update_message(UpdateMessage::Inspect);
}
Expand Down
1 change: 1 addition & 0 deletions src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub(crate) enum UpdateMessage {
Focus(ViewId),
ClearFocus(ViewId),
Active(ViewId),
ClearActive(ViewId),
WindowScale(f64),
Disabled {
id: ViewId,
Expand Down
5 changes: 5 additions & 0 deletions src/window_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,11 @@ impl WindowHandle {
id.request_style_recursive();
}
}
UpdateMessage::ClearActive(id) => {
if Some(id) == cx.app_state.active {
cx.app_state.active = None;
}
}
UpdateMessage::ScrollTo { id, rect } => {
self.id
.view()
Expand Down

0 comments on commit 1674b04

Please sign in to comment.