/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page qtquick-usecase-userinput.html
\title Use Case - Responding To User Input in QML
\brief Example of how to accept user input and respond to it in a QML application

\section1 Supported Types of User Input

The \l QtQuick module provides support for the most common types of user input,
including mouse and touch events, text input and key-press events.  Other
modules provide support for other types of user input (for example, the
\l QtSensors module provides support for shake-gestures in QML applications).

This article covers how to handle basic user input; for further information
about motion-gesture support, please see the \l QtSensors documentation. For
information about audio-visual input, please see the \l QtMultimedia documentation.

\section2 Mouse and Touch Events

The \l MouseArea type allows mouse and touch events to be handled in a QML
application.  A \l MouseArea can be combined with either an \l Image or a
\l Rectangle and \l Text object to implement a simple button.

\snippet qml/usecases/userinput.qml 0

For more advanced use cases requiring multiple touch points, please read the
documentation for the \l MultiPointTouchArea element and the \l PinchArea element.

Note that some elements have their own built in input handling. For example,
\l Flickable responds to mouse dragging, mouse wheel scrolling, touch dragging,
and touch flicking by default.

\section2 Keyboard and Button Events

Button and key presses, from buttons on a device, a keypad, or a keyboard,
can all be handled using the \l Keys attached property. This attached property
is available on all \l Item derived elements, and works with the \l Item::focus property
to determine which element receives the key event. For simple key handling, you can set the focus
to true on a single \l Item and do all your key handling there.

\snippet qml/usecases/userinput-keys.qml 0

For text input the \l QtQuick module provides several built-in types.
In particular, the \l TextInput and \l TextEdit types allow for single-line
entry and multi-line editing respectively.

Here is all you need to get a working TextInput:

\code
import QtQuick 2.0

TextInput {
    focus: true
    text: "Initial Text"
}
\endcode

*/
