@@ -435,43 +435,15 @@ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { }
435435 */
436436 }
437437 JMenuItem item ;
438- InputMap inputMap = editor .getRootPane ().getInputMap (JComponent .WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
439- ActionMap actionMap = editor .getRootPane ().getActionMap ();
438+ final JRootPane rootPane = editor .getRootPane ();
439+ InputMap inputMap =
440+ rootPane .getInputMap (JComponent .WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
441+ ActionMap actionMap = rootPane .getActionMap ();
442+
440443 Action action ;
441444 String mapKey ;
442445 KeyStroke keyStroke ;
443446
444- // maybe this shouldn't have a command key anyways..
445- // since we're not trying to make this a full ide..
446- //item = Editor.newJMenuItem("New", 'T');
447-
448- /*
449- item = Editor.newJMenuItem("Previous", KeyEvent.VK_PAGE_UP);
450- item.addActionListener(new ActionListener() {
451- public void actionPerformed(ActionEvent e) {
452- System.out.println("prev");
453- }
454- });
455- if (editor.sketch != null) {
456- item.setEnabled(editor.sketch.codeCount > 1);
457- }
458- menu.add(item);
459-
460- item = Editor.newJMenuItem("Next", KeyEvent.VK_PAGE_DOWN);
461- item.addActionListener(new ActionListener() {
462- public void actionPerformed(ActionEvent e) {
463- System.out.println("ext");
464- }
465- });
466- if (editor.sketch != null) {
467- item.setEnabled(editor.sketch.codeCount > 1);
468- }
469- menu.add(item);
470-
471- menu.addSeparator();
472- */
473-
474- //item = new JMenuItem("New Tab");
475447 item = Toolkit .newJMenuItemShift (Language .text ("editor.header.new_tab" ), KeyEvent .VK_N );
476448 action = new AbstractAction () {
477449 @ Override
@@ -491,12 +463,6 @@ public void actionPerformed(ActionEvent e) {
491463 @ Override
492464 public void actionPerformed (ActionEvent e ) {
493465 editor .getSketch ().handleRenameCode ();
494- /*
495- // this is already being called by nameCode(), the second stage of rename
496- if (editor.sketch.current == editor.sketch.code[0]) {
497- editor.sketchbook.rebuildMenus();
498- }
499- */
500466 }
501467 };
502468 item .addActionListener (action );
@@ -527,33 +493,48 @@ public void actionPerformed(ActionEvent e) {
527493 menu .addSeparator ();
528494
529495 // KeyEvent.VK_LEFT and VK_RIGHT will make Windows beep
530- item = Toolkit .newJMenuItemAlt (Language .text ("editor.header.previous_tab" ), KeyEvent .VK_LEFT );
496+
497+ final String prevTab = Language .text ("editor.header.previous_tab" );
498+ if (Base .isLinux ()) {
499+ item = Toolkit .newJMenuItem (prevTab , KeyEvent .VK_PAGE_UP );
500+ } else {
501+ item = Toolkit .newJMenuItemAlt (prevTab , KeyEvent .VK_LEFT );
502+ }
531503 action = new AbstractAction () {
532504 @ Override
533505 public void actionPerformed (ActionEvent e ) {
534- // Sketch sketch = editor.getSketch();
535- // sketch.setCurrentCode(sketch.getCurrentCodeIndex() - 1);
536506 editor .getSketch ().handlePrevCode ();
537507 }
538508 };
539509 mapKey = "editor.header.previous_tab" ;
540- keyStroke = KeyStroke .getKeyStroke (KeyEvent .VK_LEFT , Toolkit .SHORTCUT_ALT_KEY_MASK );
510+ if (Base .isLinux ()) {
511+ keyStroke = KeyStroke .getKeyStroke (KeyEvent .VK_PAGE_UP , Toolkit .SHORTCUT_KEY_MASK );
512+ } else {
513+ keyStroke = KeyStroke .getKeyStroke (KeyEvent .VK_LEFT , Toolkit .SHORTCUT_ALT_KEY_MASK );
514+ }
541515 inputMap .put (keyStroke , mapKey );
542516 actionMap .put (mapKey , action );
543517 item .addActionListener (action );
544518 menu .add (item );
545519
546- item = Toolkit .newJMenuItemAlt (Language .text ("editor.header.next_tab" ), KeyEvent .VK_RIGHT );
520+ final String nextTab = Language .text ("editor.header.next_tab" );
521+ if (Base .isLinux ()) {
522+ item = Toolkit .newJMenuItem (nextTab , KeyEvent .VK_PAGE_DOWN );
523+ } else {
524+ item = Toolkit .newJMenuItemAlt (nextTab , KeyEvent .VK_RIGHT );
525+ }
547526 action = new AbstractAction () {
548527 @ Override
549528 public void actionPerformed (ActionEvent e ) {
550- // Sketch sketch = editor.getSketch();
551- // sketch.setCurrentCode(sketch.getCurrentCodeIndex() + 1);
552529 editor .getSketch ().handleNextCode ();
553530 }
554531 };
555532 mapKey = "editor.header.next_tab" ;
556- keyStroke = KeyStroke .getKeyStroke (KeyEvent .VK_RIGHT , Toolkit .SHORTCUT_ALT_KEY_MASK );
533+ if (Base .isLinux ()) {
534+ keyStroke = KeyStroke .getKeyStroke (KeyEvent .VK_PAGE_DOWN , Toolkit .SHORTCUT_KEY_MASK );
535+ } else {
536+ keyStroke = KeyStroke .getKeyStroke (KeyEvent .VK_RIGHT , Toolkit .SHORTCUT_ALT_KEY_MASK );
537+ }
557538 inputMap .put (keyStroke , mapKey );
558539 actionMap .put (mapKey , action );
559540 item .addActionListener (action );
0 commit comments