summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativetextedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp82
1 files changed, 42 insertions, 40 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 94973f2833..3b4f2a709c 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -62,25 +62,28 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass TextEdit QDeclarativeTextEdit
\since 4.7
- \brief The TextEdit item allows you to add editable formatted text to a scene.
+ \brief The TextEdit item displays multiple lines of editable formatted text.
\inherits Item
+ The TextEdit item displays a block of editable, formatted text.
+
It can display both plain and rich text. For example:
\qml
TextEdit {
- id: edit
+ width: 240
text: "<b>Hello</b> <i>World!</i>"
- focus: true
font.family: "Helvetica"
font.pointSize: 20
color: "blue"
- width: 240
+ focus: true
}
\endqml
\image declarative-textedit.gif
+ Setting \l {Item::focus}{focus} to \c true enables the TextEdit item to receive keyboard focus.
+
Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific
to a look-and-feel. For example, to add flickable scrolling that follows the cursor:
@@ -96,7 +99,7 @@ TextEdit {
You can translate between cursor positions (characters from the start of the document) and pixel
points using positionAt() and positionToRectangle().
- \sa Text
+ \sa Text, TextInput
*/
/*!
@@ -110,7 +113,7 @@ TextEdit {
\image declarative-textedit.png
- A QDeclarativeTextEdit object can be instantiated in Qml using the tag \c &lt;TextEdit&gt;.
+ A QDeclarativeTextEdit object can be instantiated in QML using the tag \c &lt;TextEdit&gt;.
*/
/*!
@@ -206,7 +209,7 @@ QString QDeclarativeTextEdit::text() const
Sets the font size in pixels.
Using this function makes the font device dependent.
- Use \c pointSize to set the size of the font in a device independent manner.
+ Use \l pointSize to set the size of the font in a device independent manner.
*/
/*!
@@ -453,12 +456,22 @@ void QDeclarativeTextEdit::setSelectedTextColor(const QColor &color)
\qmlproperty enumeration TextEdit::horizontalAlignment
\qmlproperty enumeration TextEdit::verticalAlignment
- Sets the horizontal and vertical alignment of the text within the TextEdit items
+ Sets the horizontal and vertical alignment of the text within the TextEdit item's
width and height. By default, the text is top-left aligned.
- The valid values for \c horizontalAlignment are \c TextEdit.AlignLeft, \c TextEdit.AlignRight and
- \c TextEdit.AlignHCenter. The valid values for \c verticalAlignment are \c TextEdit.AlignTop, \c TextEdit.AlignBottom
- and \c TextEdit.AlignVCenter.
+ Valid values for \c horizontalAlignment are:
+ \list
+ \o TextEdit.AlignLeft (default)
+ \o TextEdit.AlignRight
+ \o TextEdit.AlignHCenter
+ \endlist
+
+ Valid values for \c verticalAlignment are:
+ \list
+ \o TextEdit.AlignTop (default)
+ \o TextEdit.AlignBottom
+ \c TextEdit.AlignVCenter
+ \endlist
*/
QDeclarativeTextEdit::HAlignment QDeclarativeTextEdit::hAlign() const
{
@@ -529,8 +542,8 @@ void QDeclarativeTextEdit::setWrapMode(WrapMode mode)
/*!
\qmlproperty real TextEdit::paintedWidth
- Returns the width of the text, including width past the width
- which is covered due to insufficient wrapping if WrapMode is set.
+ Returns the width of the text, including the width past the width
+ which is covered due to insufficient wrapping if \l wrapMode is set.
*/
qreal QDeclarativeTextEdit::paintedWidth() const
{
@@ -540,8 +553,8 @@ qreal QDeclarativeTextEdit::paintedWidth() const
/*!
\qmlproperty real TextEdit::paintedHeight
- Returns the height of the text, including height past the height
- which is covered due to there being more text than fits in the set height.
+ Returns the height of the text, including the height past the height
+ that is covered if the text does not fit within the set height.
*/
qreal QDeclarativeTextEdit::paintedHeight() const
{
@@ -567,10 +580,10 @@ QRectF QDeclarativeTextEdit::positionToRectangle(int pos) const
/*!
\qmlmethod int TextEdit::positionAt(x,y)
- Returns the text position closest to pixel position (\a x,\a y).
+ Returns the text position closest to pixel position (\a x, \a y).
Position 0 is before the first character, position 1 is after the first character
- but before the second, and so on until position text.length, which is after all characters.
+ but before the second, and so on until position \l {text}.length, which is after all characters.
*/
int QDeclarativeTextEdit::positionAt(int x, int y) const
{
@@ -1082,7 +1095,7 @@ void QDeclarativeTextEdit::copy()
/*!
\qmlmethod TextEdit::paste()
- Relaces the currently selected text by the contents of the system clipboard.
+ Replaces the currently selected text by the contents of the system clipboard.
*/
void QDeclarativeTextEdit::paste()
{
@@ -1391,11 +1404,11 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption()
your application.
By default the opening of input panels follows the platform style. On Symbian^1 and
- Symbian^3 -based devices the panels are opened by clicking TextEdit and need to be
- manually closed by the user. On other platforms the panels are automatically opened
- when TextEdit element gains focus and closed when the focus is lost.
+ Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms
+ the panels are automatically opened when TextEdit element gains focus. Input panels are
+ always closed if no editor owns focus.
- . You can disable the automatic behavior by setting the property \c focusOnPress to false
+ You can disable the automatic behavior by setting the property \c focusOnPress to false
and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement
the behavior you want.
@@ -1415,9 +1428,9 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption()
textEdit.openSoftwareInputPanel();
} else {
textEdit.focus = false;
- textEdit.closeSoftwareInputPanel();
}
}
+ onPressAndHold: textEdit.closeSoftwareInputPanel();
}
}
\endcode
@@ -1442,11 +1455,11 @@ void QDeclarativeTextEdit::openSoftwareInputPanel()
your application.
By default the opening of input panels follows the platform style. On Symbian^1 and
- Symbian^3 -based devices the panels are opened by clicking TextEdit and need to be
- manually closed by the user. On other platforms the panels are automatically opened
- when TextEdit element gains focus and closed when the focus is lost.
+ Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms
+ the panels are automatically opened when TextEdit element gains focus. Input panels are
+ always closed if no editor owns focus.
- . You can disable the automatic behavior by setting the property \c focusOnPress to false
+ You can disable the automatic behavior by setting the property \c focusOnPress to false
and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement
the behavior you want.
@@ -1466,9 +1479,9 @@ void QDeclarativeTextEdit::openSoftwareInputPanel()
textEdit.openSoftwareInputPanel();
} else {
textEdit.focus = false;
- textEdit.closeSoftwareInputPanel();
}
}
+ onPressAndHold: textEdit.closeSoftwareInputPanel();
}
}
\endcode
@@ -1489,22 +1502,11 @@ void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event)
{
Q_D(const QDeclarativeTextEdit);
if (d->showInputPanelOnFocus) {
- if (d->focusOnPress && !isReadOnly() && event->reason() != Qt::ActiveWindowFocusReason) {
+ if (d->focusOnPress && !isReadOnly()) {
openSoftwareInputPanel();
}
}
QDeclarativePaintedItem::focusInEvent(event);
}
-void QDeclarativeTextEdit::focusOutEvent(QFocusEvent *event)
-{
- Q_D(const QDeclarativeTextEdit);
- if (d->showInputPanelOnFocus) {
- if (d->focusOnPress && !isReadOnly()) {
- closeSoftwareInputPanel();
- }
- }
- QDeclarativePaintedItem::focusOutEvent(event);
-}
-
QT_END_NAMESPACE