[Scummvm-git-logs] scummvm master -> 0a5743bbc9d889305ec7ddf71634630cfab7e1d0
sev-
noreply at scummvm.org
Fri Feb 13 09:45:02 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
0a5743bbc9 GUI: Fix Arrow key navigation in Grouped List
Commit: 0a5743bbc9d889305ec7ddf71634630cfab7e1d0
https://github.com/scummvm/scummvm/commit/0a5743bbc9d889305ec7ddf71634630cfab7e1d0
Author: Mohit Bankar (mohitbankar1212 at gmail.com)
Date: 2026-02-13T10:44:56+01:00
Commit Message:
GUI: Fix Arrow key navigation in Grouped List
up/down arrow key navigation or selection in Grouped List now completely skips Group Headers
Changed paths:
gui/widgets/groupedlist.cpp
gui/widgets/groupedlist.h
gui/widgets/list.cpp
gui/widgets/list.h
diff --git a/gui/widgets/groupedlist.cpp b/gui/widgets/groupedlist.cpp
index 54b1efc1412..56c0f673811 100644
--- a/gui/widgets/groupedlist.cpp
+++ b/gui/widgets/groupedlist.cpp
@@ -506,4 +506,10 @@ ThemeEngine::WidgetStateInfo GroupedListWidget::getItemState(int item) const {
return _state;
}
+bool GroupedListWidget::isItemSelectable(int item) const {
+ if (item < 0 || item >= (int)_listIndex.size())
+ return false;
+ return !isGroupHeader(_listIndex[item]);
+}
+
} // End of namespace GUI
diff --git a/gui/widgets/groupedlist.h b/gui/widgets/groupedlist.h
index f3171785abe..645fffdd48a 100644
--- a/gui/widgets/groupedlist.h
+++ b/gui/widgets/groupedlist.h
@@ -71,6 +71,8 @@ public:
void startEditMode() override { error("Edit mode is not supported for Grouped Lists"); }
+ bool isItemSelectable(int item) const override;
+
protected:
void sortGroups();
void toggleGroup(int groupID);
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index 369eb7f57ec..5de6dd56abd 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -556,18 +556,31 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
if (_selectedItem < (int)_list.size() - 1) {
if ( g_system->getEventManager()->getModifierState() & Common::KBD_SHIFT) {
int newItem = _selectedItem + 1;
- if (_lastSelectionStartItem < newItem)
- markSelectedItem(newItem, true);
- else
- markSelectedItem(_selectedItem, false);
- _selectedItem = newItem;
+ // Skip selecting Group Headers
+ while (newItem < (int)_list.size() && !isItemSelectable(newItem)) {
+ newItem++;
+ }
+ if (newItem < (int)_list.size()) {
+ if (_lastSelectionStartItem < newItem)
+ markSelectedItem(newItem, true);
+ else
+ markSelectedItem(_selectedItem, false);
+ _selectedItem = newItem;
+ }
} else {
clearSelection();
- _selectedItem++;
+ int newItem = _selectedItem + 1;
+ // Skip selecting Group Headers
+ while (newItem < (int)_list.size() && !isItemSelectable(newItem)) {
+ newItem++;
+ }
+ if (newItem < (int)_list.size())
+ _selectedItem = newItem;
+ // If dead end, restore the previous selection
markSelectedItem(_selectedItem, true);
_lastSelectionStartItem = _selectedItem;
}
- if (!isItemVisible(_selectedItem))
+ if (_selectedItem < (int)_list.size() && !isItemVisible(_selectedItem))
scrollToCurrent();
}
break;
@@ -607,18 +620,31 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
if (_selectedItem > 0) {
if (g_system->getEventManager()->getModifierState() & Common::KBD_SHIFT) {
int newItem = _selectedItem - 1;
- if (_lastSelectionStartItem > newItem)
- markSelectedItem(newItem, true);
- else
- markSelectedItem(_selectedItem, false);
- _selectedItem = newItem;
+ // Skip selecting Group Headers
+ while (newItem >= 0 && !isItemSelectable(newItem)) {
+ newItem--;
+ }
+ if (newItem >= 0) {
+ if (_lastSelectionStartItem > newItem)
+ markSelectedItem(newItem, true);
+ else
+ markSelectedItem(_selectedItem, false);
+ _selectedItem = newItem;
+ }
} else {
clearSelection();
- _selectedItem--;
+ int newItem = _selectedItem - 1;
+ // Skip selecting Group Headers
+ while (newItem >= 0 && !isItemSelectable(newItem)) {
+ newItem--;
+ }
+ if (newItem >= 0)
+ _selectedItem = newItem;
+ // If dead end, restore the previous selection
markSelectedItem(_selectedItem, true);
_lastSelectionStartItem = _selectedItem;
}
- if (!isItemVisible(_selectedItem))
+ if (_selectedItem >= 0 && !isItemVisible(_selectedItem))
scrollToCurrent();
}
break;
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index 71dce978a9b..587a78df36d 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -198,6 +198,9 @@ protected:
/// Find the visual position of a data item
int findDataIndex(int dataIndex) const;
+ /// Check if an item at a given position is selectable
+ virtual bool isItemSelectable(int item) const { return true; }
+
virtual ThemeEngine::WidgetStateInfo getItemState(int item) const { return _state; }
void drawFormattedText(const Common::Rect &r, const Common::U32String &str, ThemeEngine::WidgetStateInfo state = ThemeEngine::kStateEnabled,
More information about the Scummvm-git-logs
mailing list