|
40 | 40 | * Find & Replace window for the Processing editor.
|
41 | 41 | */
|
42 | 42 | public class FindReplace extends JFrame {
|
43 |
| - Editor editor; |
| 43 | + final Editor editor; |
44 | 44 |
|
45 | 45 | static final int BORDER = Platform.isMacOS() ? 20 : 13;
|
46 | 46 |
|
@@ -200,6 +200,35 @@ public void windowActivated(WindowEvent e) {
|
200 | 200 | findField.selectAll();
|
201 | 201 | }
|
202 | 202 | });
|
| 203 | + |
| 204 | + // An attempt to set the menu bar so that key shortcuts for Find items |
| 205 | + // work from inside this window. Unfortunately, it breaks on macOS because |
| 206 | + // closing the window triggers the "default" JMenuBar, no matter what. |
| 207 | + // It works fine when going back and forth between the Find window and the |
| 208 | + // Editor window, but then when you close the Find window, the Editor |
| 209 | + // has only the default menu bar. The last setJMenuBar() call inside |
| 210 | + // windowDeactivated() seems to be ignored. Or maybe it's immediately |
| 211 | + // replaced? Oddly, the key shortcuts still work, so it may be that the |
| 212 | + // menu bar itself is simply not (visually) updated. [fry 230116] |
| 213 | + /* |
| 214 | + addWindowListener(new WindowAdapter() { |
| 215 | + JMenuBar editorMenuBar; |
| 216 | +
|
| 217 | + public void windowActivated(WindowEvent e) { |
| 218 | + // Steal the menu bar from the Editor |
| 219 | + if (editorMenuBar == null) { |
| 220 | + editorMenuBar = editor.getJMenuBar(); |
| 221 | + } |
| 222 | + setJMenuBar(editorMenuBar); |
| 223 | + } |
| 224 | +
|
| 225 | + @Override |
| 226 | + public void windowDeactivated(WindowEvent e) { |
| 227 | + editor.setJMenuBar(editorMenuBar); |
| 228 | + } |
| 229 | + }); |
| 230 | + */ |
| 231 | + |
203 | 232 | pack();
|
204 | 233 | setResizable(true);
|
205 | 234 | setLocationRelativeTo(null);
|
|
0 commit comments