Fix arrow keys in gallery

This commit is contained in:
Jeremy Soller 2024-10-10 10:11:28 -06:00
parent 081156670e
commit f54f2efa6a
No known key found for this signature in database
GPG key ID: D02FD439211AF56F

View file

@ -2288,7 +2288,13 @@ impl Tab {
}
}
Message::ItemDown => {
if let Some((row, col)) = self.select_focus_pos_opt().or(self.select_last_pos_opt())
if self.gallery {
for command in self.update(Message::GalleryNext, modifiers) {
commands.push(command);
}
} else {
if let Some((row, col)) =
self.select_focus_pos_opt().or(self.select_last_pos_opt())
{
if self.select_focus.is_none() {
// Select last item in current selection to focus it.
@ -2316,7 +2322,13 @@ impl Tab {
commands.push(Command::Iced(widget::button::focus(id)));
}
}
}
Message::ItemLeft => {
if self.gallery {
for command in self.update(Message::GalleryPrevious, modifiers) {
commands.push(command);
}
} else {
if let Some((row, col)) =
self.select_focus_pos_opt().or(self.select_first_pos_opt())
{
@ -2364,8 +2376,15 @@ impl Tab {
commands.push(Command::Iced(widget::button::focus(id)));
}
}
}
Message::ItemRight => {
if let Some((row, col)) = self.select_focus_pos_opt().or(self.select_last_pos_opt())
if self.gallery {
for command in self.update(Message::GalleryNext, modifiers) {
commands.push(command);
}
} else {
if let Some((row, col)) =
self.select_focus_pos_opt().or(self.select_last_pos_opt())
{
if self.select_focus.is_none() {
// Select last item in current selection to focus it.
@ -2394,7 +2413,13 @@ impl Tab {
commands.push(Command::Iced(widget::button::focus(id)));
}
}
}
Message::ItemUp => {
if self.gallery {
for command in self.update(Message::GalleryPrevious, modifiers) {
commands.push(command);
}
} else {
if let Some((row, col)) =
self.select_focus_pos_opt().or(self.select_first_pos_opt())
{
@ -2427,6 +2452,7 @@ impl Tab {
commands.push(Command::Iced(widget::button::focus(id)));
}
}
}
Message::Location(location) => {
// Workaround to support favorited files
match &location {