mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-31 20:52:13 +01:00
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).
This commit is contained in:
parent
57a931c9c4
commit
6c3c1c09b1
@ -1473,6 +1473,7 @@ public class Base {
|
|||||||
customMenu.putClientProperty("platform", getPlatformUniqueId(targetPlatform));
|
customMenu.putClientProperty("platform", getPlatformUniqueId(targetPlatform));
|
||||||
customMenu.putClientProperty("removeOnWindowDeactivation", true);
|
customMenu.putClientProperty("removeOnWindowDeactivation", true);
|
||||||
boardsCustomMenus.add(customMenu);
|
boardsCustomMenus.add(customMenu);
|
||||||
|
MenuScroller.setScrollerFor(customMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import java.awt.event.ActionListener;
|
|||||||
import java.awt.event.MouseWheelEvent;
|
import java.awt.event.MouseWheelEvent;
|
||||||
import java.awt.event.MouseWheelListener;
|
import java.awt.event.MouseWheelListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that provides scrolling capabilities to a long menu dropdown or
|
* A class that provides scrolling capabilities to a long menu dropdown or
|
||||||
@ -539,7 +540,7 @@ public class MenuScroller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMenuItems() {
|
private void setMenuItems() {
|
||||||
menuItems = menu.getComponents();
|
menuItems = Arrays.stream(menu.getComponents()).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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user