1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Disable cut and copy if there is not selected text

This commit is contained in:
Arturo Vargas 2016-03-31 15:01:22 -07:00
parent a7ca976623
commit baa8a6e8a3

View File

@ -1369,8 +1369,6 @@ public class Editor extends JFrame implements RunnerListener {
menu.addSeparator();
// TODO "cut" and "copy" should really only be enabled
// if some text is currently selected
JMenuItem cutItem = newJMenuItem(tr("Cut"), 'X');
cutItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -1515,6 +1513,21 @@ public class Editor extends JFrame implements RunnerListener {
menu.add(useSelectionForFindItem);
}
menu.addMenuListener(new MenuListener() {
@Override
public void menuSelected(MenuEvent e) {
boolean enabled = textarea.getSelectedText() != null;
cutItem.setEnabled(enabled);
copyItem.setEnabled(enabled);
}
@Override
public void menuDeselected(MenuEvent e) {}
@Override
public void menuCanceled(MenuEvent e) {}
});
return menu;
}