4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-selection-TreeModel'>/**
19 </span> * @class Ext.selection.TreeModel
20 * @extends Ext.selection.RowModel
22 * Adds custom behavior for left/right keyboard navigation for use with a tree.
23 * Depends on the view having an expand and collapse method which accepts a
28 Ext.define('Ext.selection.TreeModel', {
29 extend: 'Ext.selection.RowModel',
30 alias: 'selection.treemodel',
32 // typically selection models prune records from the selection
33 // model when they are removed, because the TreeView constantly
34 // adds/removes records as they are expanded/collapsed
37 onKeyRight: function(e, t) {
38 var focused = this.getLastFocused(),
42 // tree node is already expanded, go down instead
43 // this handles both the case where we navigate to firstChild and if
44 // there are no children to the nextSibling
45 if (focused.isExpanded()) {
47 // if its not a leaf node, expand it
48 } else if (!focused.isLeaf()) {
54 onKeyLeft: function(e, t) {
55 var focused = this.getLastFocused(),
57 viewSm = view.getSelectionModel(),
58 parentNode, parentRecord;
61 parentNode = focused.parentNode;
62 // if focused node is already expanded, collapse it
63 if (focused.isExpanded()) {
64 view.collapse(focused);
65 // has a parentNode and its not root
66 // TODO: this needs to cover the case where the root isVisible
67 } else if (parentNode && !parentNode.isRoot()) {
68 // Select a range of records when doing multiple selection.
70 viewSm.selectRange(parentNode, focused, e.ctrlKey, 'up');
71 viewSm.setLastFocused(parentNode);
72 // just move focus, not selection
73 } else if (e.ctrlKey) {
74 viewSm.setLastFocused(parentNode);
77 viewSm.select(parentNode);
83 onKeyPress: function(e, t) {
88 if (key === e.SPACE || key === e.ENTER) {
90 selected = this.getLastSelected();
92 this.view.onCheckChange(selected);
95 this.callParent(arguments);