Skip to content

Commit 6c3c1c0

Browse files
committed
Make Custom menus scrollable
Fixes #11416 The patch on MenuScroller.java is needed to avoid a clash between custom menus with the same label. This behaviour artificially increases the amount of objects that the scroller will calculate. Eg. if two boards share the same custom menu, that menu will contain the properties for both the boards (since it's parsed twice).
1 parent 57a931c commit 6c3c1c0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

app/src/processing/app/Base.java

+1
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,7 @@ public void actionPerformed(ActionEvent actionevent) {
14731473
customMenu.putClientProperty("platform", getPlatformUniqueId(targetPlatform));
14741474
customMenu.putClientProperty("removeOnWindowDeactivation", true);
14751475
boardsCustomMenus.add(customMenu);
1476+
MenuScroller.setScrollerFor(customMenu);
14761477
}
14771478
}
14781479
}

app/src/processing/app/tools/MenuScroller.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.awt.event.MouseWheelEvent;
1717
import java.awt.event.MouseWheelListener;
1818
import java.awt.event.KeyEvent;
19+
import java.util.Arrays;
1920

2021
/**
2122
* A class that provides scrolling capabilities to a long menu dropdown or
@@ -539,7 +540,7 @@ public void popupMenuCanceled(PopupMenuEvent e) {
539540
}
540541

541542
private void setMenuItems() {
542-
menuItems = menu.getComponents();
543+
menuItems = Arrays.stream(menu.getComponents()).filter(x -> x.isVisible()).toArray(Component[]::new);
543544
if (keepVisibleIndex >= topFixedCount
544545
&& keepVisibleIndex <= menuItems.length - bottomFixedCount
545546
&& (keepVisibleIndex > firstIndex + scrollCount

0 commit comments

Comments
 (0)