Skip to content

Commit

Permalink
Merge pull request arduino#2907 from PaulStoffregen/tools-menu-show-s…
Browse files Browse the repository at this point in the history
…ettings

Show sub-menu settings in Tools menu
  • Loading branch information
ffissore committed Apr 7, 2015
2 parents ca5f1d4 + 750534f commit 0757967
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,32 @@ public void menuDeselected(MenuEvent e) {}
public void menuSelected(MenuEvent e) {
//System.out.println("Tools menu selected.");
populatePortMenu();
for (Component c : toolsMenu.getMenuComponents()) {
if ((c instanceof JMenu) && c.isVisible()) {
JMenu menu = (JMenu)c;
String name = menu.getText();
if (name == null) continue;
String basename = name;
int index = name.indexOf(':');
if (index > 0) basename = name.substring(0, index);
String sel = null;
int count = menu.getItemCount();
for (int i=0; i < count; i++) {
JMenuItem item = menu.getItem(i);
if (item != null && item.isSelected()) {
sel = item.getText();
if (sel != null) break;
}
}
if (sel == null) {
if (!name.equals(basename)) menu.setText(basename);
} else {
if (sel.length() > 17) sel = sel.substring(0, 16) + "...";
String newname = basename + ": \"" + sel + "\"";
if (!name.equals(newname)) menu.setText(newname);
}
}
}
}
});

Expand Down

0 comments on commit 0757967

Please sign in to comment.