This file is indexed.

/usr/share/qt5/doc/qtquick/qtquick-input-focus.html is in qtdeclarative5-doc-html 5.2.1-3ubuntu15.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- focus.qdoc -->
  <title>Keyboard Focus in Qt Quick | QtQuick 5.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
    <div class="main">
    <div class="main-rounded">
        <div class="navigationbar">
        <ul>
<li>Qt 5.2</li>
<li><a href="qtquick-index.html">Qt Quick</a></li>
<li>Keyboard Focus in Qt Quick</li>
<li id="buildversion">
Qt 5.2.1 Reference Documentation</li>
    </ul>
    </div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#key-handling-overview">Key Handling Overview</a></li>
<li class="level1"><a href="#querying-the-active-focus-item">Querying the Active Focus Item</a></li>
<li class="level1"><a href="#acquiring-focus-and-focus-scopes">Acquiring Focus and Focus Scopes</a></li>
<li class="level1"><a href="#advanced-uses-of-focus-scopes">Advanced uses of Focus Scopes</a></li>
</ul>
</div>
<h1 class="title">Keyboard Focus in Qt Quick</h1>
<span class="subtitle"></span>
<!-- $$$qtquick-input-focus.html-description -->
<div class="descr"> <a name="details"></a>
<p>When a key is pressed or released, a key event is generated and delivered to the focused Qt Quick <a href="qml-qtquick-item.html">Item</a>. To facilitate the construction of reusable components and to address some of the cases unique to fluid user interfaces, the Qt Quick items add a scope based extension to Qt's traditional keyboard focus model.</p>
<a name="key-handling-overview"></a>
<h2>Key Handling Overview</h2>
<p>When the user presses or releases a key, the following occurs:</p>
<ol class="1">
<li>Qt receives the key action and generates a key event.</li>
<li>If a <a href="qquickwindow.html">QQuickWindow</a> is the active window, the key event is delivered to it.</li>
<li>The key event is delivered by the scene to the <a href="qml-qtquick-item.html">Item</a> with <i>active focus</i>. If no item has active focus, the key event is ignored.</li>
<li>If the <a href="qquickitem.html">QQuickItem</a> with active focus accepts the key event, propagation stops. Otherwise the event is send to the Item's parent until the event is accepted, or the root item is reached.<p>If the <tt>Rectangle</tt> type in the following example has active focus and the <tt>A</tt> key is pressed, the event will not be propagated further. Pressing the <tt>B</tt> key the event will propagate to the root item and thus subsequently be ignored.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
    <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
    <span class="name">focus</span>: <span class="number">true</span>
    <span class="name">Keys</span>.onPressed: {
        <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_A</span>) {
            <span class="name">console</span>.<span class="name">log</span>(<span class="string">'Key A was pressed'</span>);
            <span class="name">event</span>.<span class="name">accepted</span> <span class="operator">=</span> <span class="number">true</span>;
        }
    }
}</pre>
</li>
<li>If the root <a href="qml-qtquick-item.html">Item</a> is reached, the key event is ignored and regular Qt key handling continues.</li>
</ol>
<p>See also the <a href="qml-qtquick-keys.html">Keys attached property</a> and <a href="qml-qtquick-keynavigation.html">KeyNavigation attached property</a>.</p>
<a name="querying-the-active-focus-item"></a>
<h2>Querying the Active Focus Item</h2>
<p>Whether or not an <a href="qml-qtquick-item.html">Item</a> has active focus can be queried through the property <tt>Item::activeFocus</tt> property. For example, here we have a <a href="qml-qtquick-text.html">Text</a> type whose text is determined by whether or not it has active focus.</p>
<pre class="qml">    <span class="type"><a href="qml-qtquick-text.html">Text</a></span> {
        <span class="name">text</span>: <span class="name">activeFocus</span> ? <span class="string">&quot;I have active focus!&quot;</span> : <span class="string">&quot;I do not have active focus&quot;</span>
    }</pre>
<a name="acquiring-focus-and-focus-scopes"></a>
<h2>Acquiring Focus and Focus Scopes</h2>
<p>An <a href="qml-qtquick-item.html">Item</a> requests focus by setting the <tt>focus</tt> property to <tt>true</tt>.</p>
<p>For very simple cases simply setting the <tt>focus</tt> property is sometimes sufficient. If we run the following example with qmlscene, we see that the <tt>keyHandler</tt> type has active focus and pressing the <tt>A</tt>, <tt>B</tt>, or <tt>C</tt> keys modifies the text appropriately.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
    <span class="name">color</span>: <span class="string">&quot;lightsteelblue&quot;</span>; <span class="name">width</span>: <span class="number">240</span>; <span class="name">height</span>: <span class="number">25</span>
    <span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">id</span>: <span class="name">myText</span> }
    <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
        <span class="name">id</span>: <span class="name">keyHandler</span>
        <span class="name">focus</span>: <span class="number">true</span>
        <span class="name">Keys</span>.onPressed: {
            <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_A</span>)
                <span class="name">myText</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key A was pressed'</span>
            <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_B</span>)
                <span class="name">myText</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key B was pressed'</span>
            <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_C</span>)
                <span class="name">myText</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key C was pressed'</span>
        }
    }
}</pre>
<p class="centerAlign"><img src="images/declarative-qmlfocus1.png" alt="" /></p><p>However, were the above example to be used as a reusable or imported component, this simple use of the <tt>focus</tt> property is no longer sufficient.</p>
<p>To demonstrate, we create two instances of our previously defined component and set the first one to have focus. The intention is that when the <tt>A</tt>, <tt>B</tt>, or <tt>C</tt> keys are pressed, the first of the two components receives the event and responds accordingly.</p>
<p>The code that imports and creates two MyWidget instances:</p>
<pre class="qml"><span class="comment">//Window code that imports MyWidget</span>
<span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
    <span class="name">id</span>: <span class="name">window</span>
    <span class="name">color</span>: <span class="string">&quot;white&quot;</span>; <span class="name">width</span>: <span class="number">240</span>; <span class="name">height</span>: <span class="number">150</span>

    <span class="type"><a href="qml-qtquick-column.html">Column</a></span> {
        <span class="name">anchors</span>.centerIn: <span class="name">parent</span>; <span class="name">spacing</span>: <span class="number">15</span>

        <span class="type">MyWidget</span> {
            <span class="name">focus</span>: <span class="number">true</span>             <span class="comment">//set this MyWidget to receive the focus</span>
            <span class="name">color</span>: <span class="string">&quot;lightblue&quot;</span>
        }
        <span class="type">MyWidget</span> {
            <span class="name">color</span>: <span class="string">&quot;palegreen&quot;</span>
        }
    }
}</pre>
<p>The MyWidget code:</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
    <span class="name">id</span>: <span class="name">widget</span>
    <span class="name">color</span>: <span class="string">&quot;lightsteelblue&quot;</span>; <span class="name">width</span>: <span class="number">175</span>; <span class="name">height</span>: <span class="number">25</span>; <span class="name">radius</span>: <span class="number">10</span>; <span class="name">antialiasing</span>: <span class="number">true</span>
    <span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">id</span>: <span class="name">label</span>; <span class="name">anchors</span>.centerIn: <span class="name">parent</span>}
    <span class="name">focus</span>: <span class="number">true</span>
    <span class="name">Keys</span>.onPressed: {
        <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_A</span>)
            <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key A was pressed'</span>
        <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_B</span>)
            <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key B was pressed'</span>
        <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_C</span>)
            <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key C was pressed'</span>
    }
}</pre>
<p>We would like to have the first MyWidget object to have the focus by setting its <tt>focus</tt> property to <tt>true</tt>. However, by running the code, we can confirm that the second widget receives the focus.</p>
<p class="centerAlign"><img src="images/declarative-qmlfocus2.png" alt="" /></p><p>Looking at both <tt>MyWidget</tt> and <tt>window</tt> code, the problem is evident - there are three types that set the <tt>focus</tt> property set to <tt>true</tt>. The two MyWidget sets the <tt>focus</tt> to <tt>true</tt> and the <tt>window</tt> component also sets the focus. Ultimately, only one type can have keyboard focus, and the system has to decide which type receives the focus. When the second MyWidget is created, it receives the focus because it is the last type to set its <tt>focus</tt> property to <tt>true</tt>.</p>
<p>This problem is due to visibility. The <tt>MyWidget</tt> component would like to have the focus, but it cannot control the focus when it is imported or reused. Likewise, the <tt>window</tt> component does not have the ability to know if its imported components are requesting the focus.</p>
<p>To solve this problem, the QML introduces a concept known as a <i>focus scope</i>. For existing Qt users, a focus scope is like an automatic focus proxy. A focus scope is created by declaring the <a href="qml-qtquick-focusscope.html">FocusScope</a> type.</p>
<p>In the next example, a <a href="qml-qtquick-focusscope.html">FocusScope</a> type is added to the component, and the visual result shown.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-focusscope.html">FocusScope</a></span> {

    <span class="comment">//FocusScope needs to bind to visual properties of the Rectangle</span>
    property <span class="type">alias</span> <span class="name">color</span>: <span class="name">rectangle</span>.<span class="name">color</span>
    <span class="name">x</span>: <span class="name">rectangle</span>.<span class="name">x</span>; <span class="name">y</span>: <span class="name">rectangle</span>.<span class="name">y</span>
    <span class="name">width</span>: <span class="name">rectangle</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="name">rectangle</span>.<span class="name">height</span>

    <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
        <span class="name">id</span>: <span class="name">rectangle</span>
        <span class="name">anchors</span>.centerIn: <span class="name">parent</span>
        <span class="name">color</span>: <span class="string">&quot;lightsteelblue&quot;</span>; <span class="name">width</span>: <span class="number">175</span>; <span class="name">height</span>: <span class="number">25</span>; <span class="name">radius</span>: <span class="number">10</span>; <span class="name">antialiasing</span>: <span class="number">true</span>
        <span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">id</span>: <span class="name">label</span>; <span class="name">anchors</span>.centerIn: <span class="name">parent</span> }
        <span class="name">focus</span>: <span class="number">true</span>
        <span class="name">Keys</span>.onPressed: {
            <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_A</span>)
                <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key A was pressed'</span>
            <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_B</span>)
                <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key B was pressed'</span>
            <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_C</span>)
                <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key C was pressed'</span>
        }
    }
}</pre>
<p class="centerAlign"><img src="images/declarative-qmlfocus3.png" alt="" /></p><p>Conceptually <i>focus scopes</i> are quite simple.</p>
<ul>
<li>Within each focus scope one object may have <tt>Item::focus</tt> set to <tt>true</tt>. If more than one <a href="qml-qtquick-item.html">Item</a> has the <tt>focus</tt> property set, the last type to set the <tt>focus</tt> will have the focus and the others are unset, similar to when there are no focus scopes.</li>
<li>When a focus scope receives active focus, the contained type with <tt>focus</tt> set (if any) also gets the active focus. If this type is also a <a href="qml-qtquick-focusscope.html">FocusScope</a>, the proxying behavior continues. Both the focus scope and the sub-focused item will have <tt>activeFocus</tt> property set.</li>
</ul>
<p>Note that, since the <a href="qml-qtquick-focusscope.html">FocusScope</a> type is not a visual type, the properties of its children need to be exposed to the parent item of the <a href="qml-qtquick-focusscope.html">FocusScope</a>. Layouts and positioning types will use these visual and styling properties to create the layout. In our example, the <tt>Column</tt> type cannot display the two widgets properly because the <a href="qml-qtquick-focusscope.html">FocusScope</a> lacks visual properties of its own. The MyWidget component directly binds to the <tt>rectangle</tt> properties to allow the <tt>Column</tt> type to create the layout containing the children of the <a href="qml-qtquick-focusscope.html">FocusScope</a>.</p>
<p>So far, the example has the second component statically selected. It is trivial now to extend this component to make it clickable, and add it to the original application. We still set one of the widgets as focused by default. Now, clicking either MyClickableWidget gives it focus and the other widget loses the focus.</p>
<p>The code that imports and creates two MyClickableWidget instances:</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
    <span class="name">id</span>: <span class="name">window</span>

    <span class="name">color</span>: <span class="string">&quot;white&quot;</span>; <span class="name">width</span>: <span class="number">240</span>; <span class="name">height</span>: <span class="number">150</span>

    <span class="type"><a href="qml-qtquick-column.html">Column</a></span> {
        <span class="name">anchors</span>.centerIn: <span class="name">parent</span>; <span class="name">spacing</span>: <span class="number">15</span>

        <span class="type">MyClickableWidget</span> {
            <span class="name">focus</span>: <span class="number">true</span>             <span class="comment">//set this MyWidget to receive the focus</span>
            <span class="name">color</span>: <span class="string">&quot;lightblue&quot;</span>
        }
        <span class="type">MyClickableWidget</span> {
            <span class="name">color</span>: <span class="string">&quot;palegreen&quot;</span>
        }
    }

}</pre>
<p>The MyClickableWidget code:</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-focusscope.html">FocusScope</a></span> {

    <span class="name">id</span>: <span class="name">scope</span>

    <span class="comment">//FocusScope needs to bind to visual properties of the children</span>
    property <span class="type">alias</span> <span class="name">color</span>: <span class="name">rectangle</span>.<span class="name">color</span>
    <span class="name">x</span>: <span class="name">rectangle</span>.<span class="name">x</span>; <span class="name">y</span>: <span class="name">rectangle</span>.<span class="name">y</span>
    <span class="name">width</span>: <span class="name">rectangle</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="name">rectangle</span>.<span class="name">height</span>

    <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
        <span class="name">id</span>: <span class="name">rectangle</span>
        <span class="name">anchors</span>.centerIn: <span class="name">parent</span>
        <span class="name">color</span>: <span class="string">&quot;lightsteelblue&quot;</span>; <span class="name">width</span>: <span class="number">175</span>; <span class="name">height</span>: <span class="number">25</span>; <span class="name">radius</span>: <span class="number">10</span>; <span class="name">antialiasing</span>: <span class="number">true</span>
        <span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">id</span>: <span class="name">label</span>; <span class="name">anchors</span>.centerIn: <span class="name">parent</span> }
        <span class="name">focus</span>: <span class="number">true</span>
        <span class="name">Keys</span>.onPressed: {
            <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_A</span>)
                <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key A was pressed'</span>
            <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_B</span>)
                <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key B was pressed'</span>
            <span class="keyword">else</span> <span class="keyword">if</span> (<span class="name">event</span>.<span class="name">key</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">Key_C</span>)
                <span class="name">label</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">'Key C was pressed'</span>
        }
    }
    <span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> { <span class="name">anchors</span>.fill: <span class="name">parent</span>; <span class="name">onClicked</span>: { <span class="name">scope</span>.<span class="name">focus</span> <span class="operator">=</span> <span class="number">true</span> } }
}</pre>
<p class="centerAlign"><img src="images/declarative-qmlfocus4.png" alt="" /></p><p>When a QML <a href="qml-qtquick-item.html">Item</a> explicitly relinquishes focus (by setting its <tt>focus</tt> property to <tt>false</tt> while it has active focus), the system does not automatically select another type to receive focus. That is, it is possible for there to be no currently active focus.</p>
<p>See <a href="qtquick-keyinteraction-example.html">Qt Quick Examples - Key Interaction</a> for a demonstration of moving keyboard focus between multiple areas using <a href="qml-qtquick-focusscope.html">FocusScope</a> types.</p>
<a name="advanced-uses-of-focus-scopes"></a>
<h2>Advanced uses of Focus Scopes</h2>
<p>Focus scopes allow focus to allocation to be easily partitioned. Several QML items use it to this effect.</p>
<p><a href="qml-qtquick-listview.html">ListView</a>, for example, is itself a focus scope. Generally this isn't noticeable as <a href="qml-qtquick-listview.html">ListView</a> doesn't usually have manually added visual children. By being a focus scope, <a href="qml-qtquick-listview.html">ListView</a> can focus the current list item without worrying about how that will effect the rest of the application. This allows the current item delegate to react to key presses.</p>
<p>This contrived example shows how this works. Pressing the <tt>Return</tt> key will print the name of the current list item.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
    <span class="name">color</span>: <span class="string">&quot;lightsteelblue&quot;</span>; <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">50</span>

    <span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
        <span class="name">anchors</span>.fill: <span class="name">parent</span>
        <span class="name">focus</span>: <span class="number">true</span>

        <span class="name">model</span>: <span class="name">ListModel</span> {
            <span class="type">ListElement</span> { <span class="name">name</span>: <span class="string">&quot;Bob&quot;</span> }
            <span class="type">ListElement</span> { <span class="name">name</span>: <span class="string">&quot;John&quot;</span> }
            <span class="type">ListElement</span> { <span class="name">name</span>: <span class="string">&quot;Michael&quot;</span> }
        }

        <span class="name">delegate</span>: <span class="name">FocusScope</span> {
                <span class="name">width</span>: <span class="name">childrenRect</span>.<span class="name">width</span>; <span class="name">height</span>: <span class="name">childrenRect</span>.<span class="name">height</span>
                <span class="name">x</span>:<span class="name">childrenRect</span>.<span class="name">x</span>; <span class="name">y</span>: <span class="name">childrenRect</span>.<span class="name">y</span>
                <span class="type"><a href="qml-qtquick-textinput.html">TextInput</a></span> {
                    <span class="name">focus</span>: <span class="number">true</span>
                    <span class="name">text</span>: <span class="name">name</span>
                    <span class="name">Keys</span>.onReturnPressed: <span class="name">console</span>.<span class="name">log</span>(<span class="name">name</span>)
                }
        }
    }
}</pre>
<p class="centerAlign"><img src="images/declarative-qmlfocus5.png" alt="" /></p><p>While the example is simple, there are a lot going on behind the scenes. Whenever the current item changes, the <a href="qml-qtquick-listview.html">ListView</a> sets the delegate's <tt>Item::focus</tt> property. As the <a href="qml-qtquick-listview.html">ListView</a> is a focus scope, this doesn't affect the rest of the application. However, if the <a href="qml-qtquick-listview.html">ListView</a> itself has active focus this causes the delegate itself to receive active focus. In this example, the root type of the delegate is also a focus scope, which in turn gives active focus to the <tt>Text</tt> type that actually performs the work of handling the <tt>Return</tt> key.</p>
<p>All of the QML view classes, such as <a href="qml-qtquick-pathview.html">PathView</a> and <a href="qml-qtquick-gridview.html">GridView</a>, behave in a similar manner to allow key handling in their respective delegates.</p>
</div>
<!-- @@@qtquick-input-focus.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2013 Digia Plc and/or its
   subsidiaries. Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Digia, Qt and their respective logos are trademarks of Digia Plc     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>