mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Disable cut and copy if there is not selected text
This commit is contained in:
parent
a7ca976623
commit
baa8a6e8a3
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user