}
}
- private boolean isIE6OrOpera() {
- return BrowserInfo.get().isIE6() || BrowserInfo.get().isOpera();
- }
-
/**
* Handles mouse selection
*
if (getElement() == target || ie6compatnode == target) {
// state change
toggleState();
- } else if (!readonly && inCaption && selectable) {
- // caption click = selection change && possible click event
-
- if (handleClickSelection(
- event.getCtrlKey() || event.getMetaKey(),
- event.getShiftKey())) {
- event.preventDefault();
+ } else if (!readonly && inCaption) {
+ if (selectable) {
+ // caption click = selection change && possible click
+ // event
+ if (handleClickSelection(
+ event.getCtrlKey() || event.getMetaKey(),
+ event.getShiftKey())) {
+ event.preventDefault();
+ }
+ } else {
+ // Not selectable, only focus the node.
+ setFocusedNode(this);
}
}
event.stopPropagation();
* Scroll the node into view
*/
public void setFocusedNode(TreeNode node, boolean scrollIntoView) {
+ if (!treeHasFocus && !isIE6OrOpera()) {
+ focus();
+ }
// Unfocus previously focused node
if (focusedNode != null) {
focusedNode.setFocused(false);
}
}
- if (node != null && selectable) {
+ if (node != null) {
setFocusedNode(node);
- if (!ctrl && !shift) {
- selectNode(node, true);
- } else if (shift && isMultiselect) {
- deselectAll();
- selectNodeRange(lastSelection.key, node.key);
- } else if (shift) {
- selectNode(node, true);
+ if (selectable) {
+ if (!ctrl && !shift) {
+ selectNode(node, true);
+ } else if (shift && isMultiselect) {
+ deselectAll();
+ selectNodeRange(lastSelection.key, node.key);
+ } else if (shift) {
+ selectNode(node, true);
+ }
}
}
return true;
} else if (focusedNode.getParentNode() != null) {
node = focusedNode.getParentNode();
}
- if (node != null && selectable) {
+ if (node != null) {
setFocusedNode(node);
-
- if (!ctrl && !shift) {
- selectNode(node, true);
- } else if (shift && isMultiselect) {
- deselectAll();
- selectNodeRange(lastSelection.key, node.key);
- } else if (shift) {
- selectNode(node, true);
+ if (selectable) {
+ if (!ctrl && !shift) {
+ selectNode(node, true);
+ } else if (shift && isMultiselect) {
+ deselectAll();
+ selectNodeRange(lastSelection.key, node.key);
+ } else if (shift) {
+ selectNode(node, true);
+ }
}
}
return true;
} else if (focusedNode.getParentNode() != null
&& (focusedNode.isLeaf() || !focusedNode.getState())) {
- if (ctrl) {
+ if (ctrl || !selectable) {
setFocusedNode(focusedNode.getParentNode());
} else if (shift) {
doRelationSelection(focusedNode.getParentNode(),
if (!focusedNode.isLeaf() && !focusedNode.getState()) {
focusedNode.setState(true, true);
} else if (!focusedNode.isLeaf()) {
- if (ctrl) {
+ if (ctrl || !selectable) {
setFocusedNode(focusedNode.getChildren().get(0));
} else if (shift) {
setSelected(focusedNode, true);
// Selection
if (keycode == getNavigationSelectKey()) {
if (!focusedNode.isSelected()) {
- selectNode(focusedNode, !isMultiselect
- || multiSelectMode == MULTISELECT_MODE_SIMPLE);
+ selectNode(
+ focusedNode,
+ (!isMultiselect || multiSelectMode == MULTISELECT_MODE_SIMPLE)
+ && selectable);
} else {
deselectNode(focusedNode);
}
// Home selection
if (keycode == getNavigationStartKey()) {
TreeNode node = getFirstRootNode();
- if (!ctrl && !shift) {
- selectNode(node, true);
- } else if (ctrl) {
+ if (ctrl || !selectable) {
setFocusedNode(node);
} else if (shift) {
deselectAll();
selectNodeRange(focusedNode.key, node.key);
+ } else {
+ selectNode(node, true);
}
sendSelectionToServer();
return true;
if (keycode == getNavigationEndKey()) {
TreeNode lastNode = getLastRootNode();
TreeNode node = getLastVisibleChildInTree(lastNode);
- if (!ctrl && !shift) {
- selectNode(node, true);
- } else if (ctrl) {
+ if (ctrl || !selectable) {
setFocusedNode(node);
} else if (shift) {
deselectAll();
selectNodeRange(focusedNode.key, node.key);
+ } else {
+ selectNode(node, true);
}
sendSelectionToServer();
return true;
}
}
+ private boolean isIE6OrOpera() {
+ return BrowserInfo.get().isIE6() || BrowserInfo.get().isOpera();
+ }
}