selecting files with ctrl and shift
This commit is contained in:
parent
7ec4ca8946
commit
9c2ac5c846
@ -361,9 +361,9 @@ public class FilePanelTab extends JPanel {
|
||||
// Request focus on table even if clicking on empty area
|
||||
fileTable.requestFocusInWindow();
|
||||
|
||||
// Single left-click should focus/select the item under cursor but
|
||||
// should NOT toggle its marked state. This preserves keyboard
|
||||
// marking (Insert) while making mouse clicks act as simple focus.
|
||||
// Single left-click should focus/select the item under cursor and
|
||||
// toggle its marked state if CTRL is held.
|
||||
// Note: Marking toggle is handled in MOUSE_PRESSED for better responsiveness.
|
||||
if (e.getClickCount() % 2 == 1 && javax.swing.SwingUtilities.isLeftMouseButton(e)) {
|
||||
boolean selected = false;
|
||||
if (row >= 0) {
|
||||
@ -420,6 +420,36 @@ public class FilePanelTab extends JPanel {
|
||||
FileItem item = tableModel.getItemFromBriefLayout(row, col);
|
||||
if (item != null) {
|
||||
int index = tableModel.items.indexOf(item);
|
||||
|
||||
// Handle SHIFT+click selection range
|
||||
if (e.isShiftDown()) {
|
||||
int anchorRow = fileTable.getSelectionModel().getAnchorSelectionIndex();
|
||||
int anchorCol = briefCurrentColumn;
|
||||
int anchorIndex = anchorCol * tableModel.briefRowsPerColumn + anchorRow;
|
||||
|
||||
if (anchorIndex >= 0 && anchorIndex < tableModel.items.size()) {
|
||||
int start = Math.min(anchorIndex, index);
|
||||
int end = Math.max(anchorIndex, index);
|
||||
for (int i = start; i <= end; i++) {
|
||||
FileItem rangeItem = tableModel.items.get(i);
|
||||
if (rangeItem != null && !rangeItem.getName().equals("..")) {
|
||||
rangeItem.setMarked(true);
|
||||
}
|
||||
}
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
// If CTRL is NOT pressed and SHIFT is NOT pressed, unselect all other items before selecting this one
|
||||
if (!e.isControlDown() && !e.isShiftDown()) {
|
||||
unselectAll();
|
||||
}
|
||||
// Toggle marked state if CTRL is pressed
|
||||
if (e.isControlDown() && !item.getName().equals("..")) {
|
||||
item.setMarked(!item.isMarked());
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
if (index >= 0) {
|
||||
int selRow = index % tableModel.briefRowsPerColumn;
|
||||
fileTable.setRowSelectionInterval(selRow, selRow);
|
||||
@ -428,6 +458,33 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FileItem item = tableModel.getItem(row);
|
||||
if (item != null) {
|
||||
// Handle SHIFT+click selection range
|
||||
if (e.isShiftDown()) {
|
||||
int anchorIndex = fileTable.getSelectionModel().getAnchorSelectionIndex();
|
||||
if (anchorIndex >= 0 && anchorIndex < tableModel.items.size()) {
|
||||
int start = Math.min(anchorIndex, row);
|
||||
int end = Math.max(anchorIndex, row);
|
||||
for (int i = start; i <= end; i++) {
|
||||
FileItem rangeItem = tableModel.items.get(i);
|
||||
if (rangeItem != null && !rangeItem.getName().equals("..")) {
|
||||
rangeItem.setMarked(true);
|
||||
}
|
||||
}
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
// If CTRL is NOT pressed and SHIFT is NOT pressed, unselect all other items before selecting this one
|
||||
if (!e.isControlDown() && !e.isShiftDown()) {
|
||||
unselectAll();
|
||||
}
|
||||
if (e.isControlDown() && !item.getName().equals("..")) {
|
||||
item.setMarked(!item.isMarked());
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
fileTable.setRowSelectionInterval(row, row);
|
||||
selected = true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user