scroll to selected item when using type-to-select
This commit is contained in:
parent
03ec21bdc9
commit
26634889dc
3 changed files with 14 additions and 1 deletions
|
|
@ -3063,6 +3063,12 @@ impl Application for App {
|
|||
|
||||
if let Some(tab) = self.tab_model.data_mut::<Tab>(entity) {
|
||||
tab.select_by_prefix(&self.type_select_prefix);
|
||||
if let Some(offset) = tab.select_focus_scroll() {
|
||||
return scrollable::scroll_to(
|
||||
tab.scrollable_id.clone(),
|
||||
offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use cosmic::{
|
|||
futures::{self, SinkExt},
|
||||
keyboard::{Event as KeyEvent, Key, Modifiers, key::Named},
|
||||
stream, window,
|
||||
widget::scrollable,
|
||||
},
|
||||
iced_core::widget::operation,
|
||||
iced_winit::{self, SurfaceIdWrapper},
|
||||
|
|
@ -1465,6 +1466,12 @@ impl Application for App {
|
|||
self.type_select_last_key = Some(Instant::now());
|
||||
|
||||
self.tab.select_by_prefix(&self.type_select_prefix);
|
||||
if let Some(offset) = self.tab.select_focus_scroll() {
|
||||
return scrollable::scroll_to(
|
||||
self.tab.scrollable_id.clone(),
|
||||
offset,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2942,7 +2942,7 @@ impl Tab {
|
|||
item.pos_opt.get()
|
||||
}
|
||||
|
||||
fn select_focus_scroll(&mut self) -> Option<AbsoluteOffset> {
|
||||
pub(crate) fn select_focus_scroll(&mut self) -> Option<AbsoluteOffset> {
|
||||
let items = self.items_opt.as_ref()?;
|
||||
let item = items.get(self.select_focus?)?;
|
||||
let rect = item.rect_opt.get()?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue