Added rpl::event_stream for document contents changes in InputField.

This commit is contained in:
23rd 2019-10-18 00:26:03 +03:00
parent 568f14594f
commit 24d69ee679
2 changed files with 12 additions and 0 deletions

View file

@ -2210,6 +2210,7 @@ void InputField::onDocumentContentsChange(
_correcting = false;
QTextCursor(document->docHandle(), 0).endEditBlock();
handleContentsChanged();
_documentContentsChanges.fire({position, charsRemoved, charsAdded});
});
chopByMaxLength(insertPosition, insertLength);

View file

@ -315,6 +315,15 @@ public:
int scrollTopMax() const;
void scrollTo(int top);
struct DocumentChangeInfo {
int position = 0;
int added = 0;
int removed = 0;
};
auto documentContentsChanges() {
return _documentContentsChanges.events();
}
~InputField();
private slots:
@ -514,6 +523,8 @@ private:
InstantReplaces _mutableInstantReplaces;
bool _instantReplacesEnabled = true;
rpl::event_stream<DocumentChangeInfo> _documentContentsChanges;
};
class MaskedInputField : public RpWidgetWrap<QLineEdit> {