KF7: Revise LinkButton & UrlButton signals API
Current signalling API of LinkButton consists of
signal pressed(var mouse)
signal clicked(var mouse)
but they are being abused in the very same component by Keys.onPressed
and Accessible.onPressAction
to pass fake event objects.
Moreover, as demonstrated by the UrlButton subtype, API consumers are only ever interested in right mouse button on press (to open context menu), and left mouse button on click:
onPressed: mouse => {
if (mouse.button === Qt.RightButton) {
menu.popup();
}
}
onClicked: mouse => {
if (mouse.button !== Qt.RightButton) {
Qt.openUrlExternally(url);
}
}
there are not so many choices with !== Qt.RightButton
and acceptedButtons: Qt.LeftButton | Qt.RightButton
The proposal is to redo signals with different names that would provide more restricted but targeted API.
How about this?
signal contextMenuRequested(/*nullable*/ position)
and then wrapping QtQuick/Text and adding <a>
tag to it, so that it becomes a real link, and emits Text::linkActivated(string link)
signal on its own?
Either way, wrapping or not, this component should be at least reusing linkHovered
& linkActivated
signal for compatibility and convenience.