Skip to content

Commit

Permalink
Implement reactive-rendering for combo_box
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Oct 25, 2024
1 parent c6493e2 commit ab2d29b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions widget/src/combo_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
//! }
//! }
//! ```
use crate::core::event;
use crate::core::keyboard;
use crate::core::keyboard::key;
use crate::core::layout::{self, Layout};
Expand All @@ -64,6 +63,7 @@ use crate::core::renderer;
use crate::core::text;
use crate::core::time::Instant;
use crate::core::widget::{self, Widget};
use crate::core::window;
use crate::core::{
Clipboard, Element, Event, Length, Padding, Rectangle, Shell, Size, Theme,
Vector,
Expand Down Expand Up @@ -550,10 +550,21 @@ where
viewport,
);

if local_shell.event_status() == event::Status::Captured {
if local_shell.is_event_captured() {
shell.capture_event();
}

if let Some(redraw_request) = local_shell.redraw_request() {
match redraw_request {
window::RedrawRequest::NextFrame => {
shell.request_redraw();
}
window::RedrawRequest::At(at) => {
shell.request_redraw_at(at);
}
}
}

// Then finally react to them here
for message in local_messages {
let TextInputEvent::TextChanged(new_value) = message;
Expand All @@ -580,6 +591,7 @@ where
);
});
shell.invalidate_layout();
shell.request_redraw();
}

let is_focused = {
Expand Down Expand Up @@ -624,8 +636,8 @@ where
}

shell.capture_event();
shell.request_redraw();
}

(key::Named::ArrowUp, _) | (key::Named::Tab, true) => {
if let Some(index) = &mut menu.hovered_option {
if *index == 0 {
Expand Down Expand Up @@ -661,6 +673,7 @@ where
}

shell.capture_event();
shell.request_redraw();
}
(key::Named::ArrowDown, _)
| (key::Named::Tab, false)
Expand Down Expand Up @@ -708,6 +721,7 @@ where
}

shell.capture_event();
shell.request_redraw();
}
_ => {}
}
Expand Down

0 comments on commit ab2d29b

Please sign in to comment.