Skip to content

Commit cb1b845

Browse files
committed
Preserve all menu items for restoring when the menu is closed
1 parent 6c3c1c0 commit cb1b845

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class MenuScroller {
3434

3535
private JPopupMenu menu;
3636
private Component[] menuItems;
37+
private Component[] allMenuItems;
3738
private MenuScrollItem upItem;
3839
private MenuScrollItem downItem;
3940
private final MenuScrollListener menuListener = new MenuScrollListener();
@@ -540,7 +541,8 @@ public void popupMenuCanceled(PopupMenuEvent e) {
540541
}
541542

542543
private void setMenuItems() {
543-
menuItems = Arrays.stream(menu.getComponents()).filter(x -> x.isVisible()).toArray(Component[]::new);
544+
allMenuItems = menu.getComponents();
545+
menuItems = Arrays.stream(allMenuItems).filter(x -> x.isVisible()).toArray(Component[]::new);
544546
if (keepVisibleIndex >= topFixedCount
545547
&& keepVisibleIndex <= menuItems.length - bottomFixedCount
546548
&& (keepVisibleIndex > firstIndex + scrollCount
@@ -555,7 +557,7 @@ private void setMenuItems() {
555557

556558
private void restoreMenuItems() {
557559
menu.removeAll();
558-
for (Component component : menuItems) {
560+
for (Component component : allMenuItems) {
559561
menu.add(component);
560562
}
561563
}

0 commit comments

Comments
 (0)