Add complete keyboard navigation.
This commit is contained in:
@@ -238,6 +238,7 @@ pub enum Message {
|
||||
// Settings
|
||||
SetOfflineMode(bool),
|
||||
SetUiLocale(UiLocale),
|
||||
KeyboardNavigation(crate::components::keyboard::Navigation),
|
||||
ToggleLocaleDropdown,
|
||||
ToggleProjectDropdown,
|
||||
|
||||
@@ -1457,6 +1458,10 @@ impl BdsApp {
|
||||
|
||||
pub fn update(&mut self, message: Message) -> Task<Message> {
|
||||
match message {
|
||||
Message::KeyboardNavigation(navigation) => match navigation {
|
||||
crate::components::keyboard::Navigation::Next => iced::widget::focus_next(),
|
||||
crate::components::keyboard::Navigation::Previous => iced::widget::focus_previous(),
|
||||
},
|
||||
Message::WindowCloseRequested => {
|
||||
self.persist_project_ui_state();
|
||||
flush_embeddings_and_exit(std::process::exit)
|
||||
@@ -3869,7 +3874,11 @@ impl BdsApp {
|
||||
) && (action != MenuAction::DisconnectServer || self.remote_client.is_some())
|
||||
});
|
||||
|
||||
native_edit::native_edit(content, Arc::clone(&self.native_edit_commands)).into()
|
||||
crate::components::keyboard::scope(native_edit::native_edit(
|
||||
content,
|
||||
Arc::clone(&self.native_edit_commands),
|
||||
))
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn subscription(&self) -> Subscription<Message> {
|
||||
@@ -3894,6 +3903,15 @@ impl BdsApp {
|
||||
_ => None,
|
||||
});
|
||||
let window_close_sub = window::close_requests().map(|_| Message::WindowCloseRequested);
|
||||
let keyboard_navigation_sub = iced::event::listen_with(|event, status, _id| {
|
||||
let iced::Event::Keyboard(iced::keyboard::Event::KeyPressed { key, modifiers, .. }) =
|
||||
event
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
crate::components::keyboard::tab_navigation(&key, modifiers, status)
|
||||
.map(Message::KeyboardNavigation)
|
||||
});
|
||||
|
||||
// Global mouse tracking for sidebar resize dragging.
|
||||
// The 4px drag handle mouse_area only fires on_press; move/release
|
||||
@@ -3950,6 +3968,7 @@ impl BdsApp {
|
||||
toast_tick,
|
||||
file_drop_sub,
|
||||
window_close_sub,
|
||||
keyboard_navigation_sub,
|
||||
drag_sub,
|
||||
menu_interaction_sub,
|
||||
menu_expand_tick,
|
||||
|
||||
Reference in New Issue
Block a user