Changeset 7141
- Timestamp:
- 2004-03-29T15:25:59+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java
r7123 r7141 1037 1037 private class KeyListenerImpl 1038 1038 extends KeyAdapter { 1039 private boolean vk_left_pressed = false; 1039 1040 /** Called whenever a key that was pressed is released, it is this action that will cause the desired effects (this allows for the key event itself to be processed prior to this listener dealing with it). */ 1040 1041 public void keyReleased(KeyEvent event) { … … 1064 1065 if(path != null) { 1065 1066 File file = ((FileNode)path.getLastPathComponent()).getFile(); 1066 if(file != null && file.isFile()) { 1067 TreePath parent_path = path.getParentPath(); 1068 if (parent_path != null && parent_path.getParentPath() != null) { 1069 // if this file is in the top level folder, don't move the focus 1070 tree.setImmediate(true); 1071 tree.clearSelection(); 1072 tree.setSelectionPath(parent_path); 1073 tree.setImmediate(false); 1067 if(file != null) { 1068 if (file.isFile() || vk_left_pressed) { 1069 vk_left_pressed = false; 1070 TreePath parent_path = path.getParentPath(); 1071 if (parent_path != null && parent_path.getParentPath() != null) { 1072 // if this file is in the top level folder, don't move the focus 1073 tree.setImmediate(true); 1074 tree.clearSelection(); 1075 tree.setSelectionPath(parent_path); 1076 tree.setImmediate(false); 1077 } 1074 1078 } 1075 1079 } 1076 1080 } 1081 } 1082 } 1083 1084 // we need to watch for left clicks on an unopened folder - should shift the focus to teh parent folder. But because there is some other mysterious key listener that does opening and closing folders on right and left clicks, we must detect the situation before the other handler has done its job, and process it after. 1085 public void keyPressed(KeyEvent event) { 1086 if (event.getKeyCode() == KeyEvent.VK_LEFT) { 1087 // left key on closed directory shifts the selection to the parent folder 1088 DragTree tree = (DragTree)event.getSource(); 1089 TreePath path = tree.getLeadSelectionPath(); 1090 if(path == null) return; 1091 File file = ((FileNode)path.getLastPathComponent()).getFile(); 1092 if(file == null) return; 1093 1094 if (file.isDirectory() && tree.isCollapsed(path)) { 1095 vk_left_pressed = true; 1096 } 1077 1097 } 1078 1098 }
Note:
See TracChangeset
for help on using the changeset viewer.