Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Custom menus scrollable #11425

Merged
merged 2 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,7 @@ public void actionPerformed(ActionEvent actionevent) {
customMenu.putClientProperty("platform", getPlatformUniqueId(targetPlatform));
customMenu.putClientProperty("removeOnWindowDeactivation", true);
boardsCustomMenus.add(customMenu);
MenuScroller.setScrollerFor(customMenu);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/processing/app/tools/MenuScroller.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.KeyEvent;
import java.util.Arrays;

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

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