mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-08 02:54:24 +01:00
Preserve all menu items for restoring when the menu is closed
This commit is contained in:
parent
6c3c1c09b1
commit
cb1b845fbd
@ -34,6 +34,7 @@ public class MenuScroller {
|
|||||||
|
|
||||||
private JPopupMenu menu;
|
private JPopupMenu menu;
|
||||||
private Component[] menuItems;
|
private Component[] menuItems;
|
||||||
|
private Component[] allMenuItems;
|
||||||
private MenuScrollItem upItem;
|
private MenuScrollItem upItem;
|
||||||
private MenuScrollItem downItem;
|
private MenuScrollItem downItem;
|
||||||
private final MenuScrollListener menuListener = new MenuScrollListener();
|
private final MenuScrollListener menuListener = new MenuScrollListener();
|
||||||
@ -540,7 +541,8 @@ public class MenuScroller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMenuItems() {
|
private void setMenuItems() {
|
||||||
menuItems = Arrays.stream(menu.getComponents()).filter(x -> x.isVisible()).toArray(Component[]::new);
|
allMenuItems = menu.getComponents();
|
||||||
|
menuItems = Arrays.stream(allMenuItems).filter(x -> x.isVisible()).toArray(Component[]::new);
|
||||||
if (keepVisibleIndex >= topFixedCount
|
if (keepVisibleIndex >= topFixedCount
|
||||||
&& keepVisibleIndex <= menuItems.length - bottomFixedCount
|
&& keepVisibleIndex <= menuItems.length - bottomFixedCount
|
||||||
&& (keepVisibleIndex > firstIndex + scrollCount
|
&& (keepVisibleIndex > firstIndex + scrollCount
|
||||||
@ -555,7 +557,7 @@ public class MenuScroller {
|
|||||||
|
|
||||||
private void restoreMenuItems() {
|
private void restoreMenuItems() {
|
||||||
menu.removeAll();
|
menu.removeAll();
|
||||||
for (Component component : menuItems) {
|
for (Component component : allMenuItems) {
|
||||||
menu.add(component);
|
menu.add(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user