Skip to content

Commit

Permalink
[hide] New context menu search now include submenus names
Browse files Browse the repository at this point in the history
  • Loading branch information
EspeuteClement committed Nov 8, 2024
1 parent bb01ec7 commit 0f2d47d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hide/comp/ContextMenu2.hx
Original file line number Diff line number Diff line change
Expand Up @@ -285,25 +285,26 @@ class ContextMenu2 {

var filterLower = filter.toLowerCase();

function filterElements(items: Array<MenuItem>) : Array<MenuItem> {
function filterElements(items: Array<MenuItem>, parentMatch: Bool) : Array<MenuItem> {
var filteredItems : Array<MenuItem> = [];
for (id => item in items) {
var match = parentMatch || (item.label != null && StringTools.contains(item.label.toLowerCase(), filterLower));
if (item.menu != null) {
var subItems = filterElements(item.menu);
var subItems = filterElements(item.menu, match);
if (subItems.length > 0) {
filteredItems.push({label: item.label, menu: subItems});
}
}
else {
if (item.label != null && StringTools.contains(item.label.toLowerCase(), filterLower)) {
if (match) {
filteredItems.push(item);
}
}
}
return filteredItems;
}

filteredItems = filterElements(items);
filteredItems = filterElements(items, false);

var submenuStack : Array<Iterator<MenuItem>> = [];
submenuStack.push(filteredItems.iterator());
Expand Down

0 comments on commit 0f2d47d

Please sign in to comment.