From 54da4d6d379222fa076025ebc6964f7f8b51b21b Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Thu, 14 May 2015 14:53:06 +0200 Subject: [PATCH] New editor on MacOSX: restored CMD+E for finding selected text --- app/src/processing/app/Editor.java | 55 +++++++++++++++++++----------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index dc6090276..891f46b77 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1407,40 +1407,55 @@ public class Editor extends JFrame implements RunnerListener { item = newJMenuItem(_("Find..."), 'F'); item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (find == null) { - find = new FindReplace(Editor.this); - } - if (getSelectedText()!= null) find.setFindText( getSelectedText() ); - //new FindReplace(Editor.this).show(); - find.setLocationRelativeTo(Editor.this); - find.setVisible(true); - //find.setVisible(true); + public void actionPerformed(ActionEvent e) { + if (find == null) { + find = new FindReplace(Editor.this); } - }); + if (!OSUtils.isMacOS() && getSelectedText() != null) { + find.setFindText(getSelectedText()); + } + find.setLocationRelativeTo(Editor.this); + find.setVisible(true); + } + }); menu.add(item); - // TODO find next should only be enabled after a - // search has actually taken place item = newJMenuItem(_("Find Next"), 'G'); item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (find != null) { - find.findNext(); - } + public void actionPerformed(ActionEvent e) { + if (find != null) { + find.findNext(); } - }); + } + }); menu.add(item); item = newJMenuItemShift(_("Find Previous"), 'G'); item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (find != null) { + find.findPrevious(); + } + } + }); + menu.add(item); + + if (OSUtils.isMacOS()) { + item = newJMenuItem(_("Use Selection For Find"), 'E'); + item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - if (find != null) { - find.findPrevious(); + if (find == null) { + find = new FindReplace(Editor.this); } + if (getSelectedText() != null) { + find.setFindText(getSelectedText()); + } + find.setLocationRelativeTo(Editor.this); + find.setVisible(true); } }); - menu.add(item); + menu.add(item); + } return menu; }