Skip to content

Commit

Permalink
[openrocket#1549] Select all shortcut in ComponentTree
Browse files Browse the repository at this point in the history
  • Loading branch information
SiboVG committed Jul 22, 2022
1 parent 97a891a commit 3602700
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,31 @@
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.components.BasicTree;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;


@SuppressWarnings("serial")
public class ComponentTree extends BasicTree {

public ComponentTree(OpenRocketDocument document) {
super();
this.setModel(new ComponentTreeModel(document.getRocket(), this));


addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) { }

@Override
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_A) && ((e.getModifiersEx() & KeyEvent.META_DOWN_MASK) != 0)) {
setSelectionInterval(1, getRowCount()); // Don't select the rocket (row 0)
}
}

@Override
public void keyReleased(KeyEvent e) { }
});
this.setCellRenderer(new ComponentTreeRenderer());

this.setDragEnabled(true);
Expand Down

0 comments on commit 3602700

Please sign in to comment.