[ChangeLog][QtQuick] Added Text::linkAt(x,y) method.
Task-number: QTBUG-18946
Change-Id: I3b4071c6117ac0ee636f2fdbd2c392eb05b02dd7
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
qmlRegisterType<QQuickText, 2>(uri, 2, 2, "Text");
qmlRegisterType<QQuickTextEdit, 2>(uri, 2, 2, "TextEdit");
+
+ qmlRegisterType<QQuickText, 3>(uri, 2, 3, "Text");
}
static void initResources()
text. The link must be in rich text or HTML format and the \a link
string provides access to the particular link.
- \sa hoveredLink
+ \sa hoveredLink, linkAt()
*/
/*!
embedded in the text. The link must be in rich text or HTML format
and the \a hoveredLink string provides access to the particular link.
- \sa onLinkHovered
+ \sa onLinkHovered, linkAt()
*/
QString QQuickText::hoveredLink() const
d->updateSize();
}
+/*!
+ \qmlmethod QtQuick::Text::linkAt(real x, real y)
+ \since 5.3
+
+ Returns the link string at point \a x, \a y in content coordinates,
+ or an empty string if no link exists at that point.
+
+ \sa hoveredLink
+*/
+QString QQuickText::linkAt(qreal x, qreal y) const
+{
+ Q_D(const QQuickText);
+ return d->anchorAt(QPointF(x, y));
+}
+
QT_END_NAMESPACE
QString hoveredLink() const;
+ Q_REVISION(3) Q_INVOKABLE QString linkAt(qreal x, qreal y) const;
+
Q_SIGNALS:
void textChanged(const QString &text);
void linkActivated(const QString &link);
QCOMPARE(test.hoveredLink, hoverEnterLink);
QCOMPARE(textObject->hoveredLink(), hoverEnterLink);
+ QCOMPARE(textObject->linkAt(mousePosition.x(), mousePosition.y()), hoverEnterLink);
for (int i = 1; i < mousePositions.count(); ++i) {
mousePosition = mousePositions.at(i);
QCOMPARE(test.hoveredLink, hoverMoveLink);
QCOMPARE(textObject->hoveredLink(), hoverMoveLink);
+ QCOMPARE(textObject->linkAt(mousePosition.x(), mousePosition.y()), hoverMoveLink);
{
QHoverEvent he(QEvent::HoverLeave, mousePosition, QPointF());
QCOMPARE(test.clickedLink, clickedLink);
QCOMPARE(test.hoveredLink, QString());
QCOMPARE(textObject->hoveredLink(), QString());
+ QCOMPARE(textObject->linkAt(-1, -1), QString());
delete textObject;
}