Skip to content

Commit 925fcd2

Browse files
committed
failed attempt at sharing the Editor window menu bar with the Find/Replace window
1 parent a974022 commit 925fcd2

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

app/src/processing/app/ui/FindReplace.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* Find & Replace window for the Processing editor.
4141
*/
4242
public class FindReplace extends JFrame {
43-
Editor editor;
43+
final Editor editor;
4444

4545
static final int BORDER = Platform.isMacOS() ? 20 : 13;
4646

@@ -200,6 +200,35 @@ public void windowActivated(WindowEvent e) {
200200
findField.selectAll();
201201
}
202202
});
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+
203232
pack();
204233
setResizable(true);
205234
setLocationRelativeTo(null);

0 commit comments

Comments
 (0)