summary refs log tree commit diff
path: root/resources/qml
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-10-31 23:24:07 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-11-25 19:05:11 +0100
commit7a74b863402e5f67ce7fd0a99ab3ad64b7296344 (patch)
treee930fa3ee7d43a835d014e70929656b84125672a /resources/qml
parentDisable scroll helper on mobile (diff)
downloadnheko-7a74b863402e5f67ce7fd0a99ab3ad64b7296344.tar.xz
Pasteable textinput
Diffstat (limited to 'resources/qml')
-rw-r--r--resources/qml/MessageInput.qml24
-rw-r--r--resources/qml/TimelineView.qml4
2 files changed, 25 insertions, 3 deletions
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml

index 71da9cae..3b424bb3 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml
@@ -3,6 +3,8 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 +import im.nheko 1.0 + Rectangle { color: colors.window Layout.fillWidth: true @@ -44,16 +46,36 @@ Rectangle { Layout.fillWidth: true TextArea { + id: textArea + placeholderText: qsTr("Write a message...") placeholderTextColor: colors.buttonText color: colors.text wrapMode: TextEdit.Wrap + onTextChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text) + onCursorPositionChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text) + onSelectionStartChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text) + onSelectionEndChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text) + + Keys.onPressed: { + if (event.matches(StandardKey.Paste)) { + TimelineManager.timeline.input.paste(false) || textArea.paste() + event.accepted = true + } + else if (event.matches(StandardKey.InsertParagraphSeparator)) { + TimelineManager.timeline.input.send() + textArea.clear() + event.accepted = true + } + } + MouseArea { // workaround for wrong cursor shape on some platforms anchors.fill: parent - acceptedButtons: Qt.NoButton + acceptedButtons: Qt.MiddleButton cursorShape: Qt.IBeamCursor + onClicked: TimelineManager.timeline.input.paste(true) || textArea.paste() } background: Rectangle { diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index 95143b18..d85167af 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml
@@ -234,8 +234,8 @@ Page { ReplyPopup { } - //MessageInput { - //} + MessageInput { + } }