Skip to content

Commit

Permalink
remove set id function
Browse files Browse the repository at this point in the history
  • Loading branch information
TimonPost committed Aug 23, 2023
1 parent 0ff4a04 commit 866ba78
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions crates/egui/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,6 @@ impl Interaction {
}

impl Focus {
pub fn set_id(&mut self, id: Id) {
self.id = Some(id);
}

/// Which widget currently has keyboard focus?
pub fn focused(&self) -> Option<Id> {
self.id
Expand All @@ -268,7 +264,7 @@ impl Focus {
fn begin_frame(&mut self, new_input: &crate::data::input::RawInput) {
self.id_previous_frame = self.id;
if let Some(id) = self.id_next_frame.take() {
self.set_id(id);
self.id = Some(id);
}

#[cfg(feature = "accesskit")]
Expand Down Expand Up @@ -333,7 +329,7 @@ impl Focus {
FocusDirection::None | FocusDirection::Previous | FocusDirection::Next
) {
if let Some(found_widget) = self.find_widget_in_direction(used_ids) {
self.set_id(found_widget);
self.id = Some(found_widget);
}
}

Expand All @@ -356,7 +352,7 @@ impl Focus {
#[cfg(feature = "accesskit")]
{
if self.id_requested_by_accesskit == Some(id.accesskit_id()) {
self.set_id(id);
self.id = Some(id);
self.id_requested_by_accesskit = None;
self.give_to_next = false;
self.reset_focus();
Expand All @@ -369,7 +365,7 @@ impl Focus {
.or_insert(Rect::EVERYTHING);

if self.give_to_next && !self.had_focus_last_frame(id) {
self.set_id(id);
self.id = Some(id);
self.give_to_next = false;
} else if self.id == Some(id) {
if matches!(self.focus_direction, FocusDirection::Next) && !self.is_focus_locked {
Expand All @@ -387,7 +383,7 @@ impl Focus {
&& !self.give_to_next
{
// nothing has focus and the user pressed tab - give focus to the first widgets that wants it:
self.set_id(id);
self.id = Some(id);
self.reset_focus();
}

Expand Down Expand Up @@ -558,7 +554,7 @@ impl Memory {
/// See also [`crate::Response::request_focus`].
#[inline(always)]
pub fn request_focus(&mut self, id: Id) {
self.interaction.focus.set_id(id);
self.interaction.focus.id = Some(id);
self.interaction.focus.is_focus_locked = false;
}

Expand Down

0 comments on commit 866ba78

Please sign in to comment.