2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-03 16:15:13 +00:00

Clear formatting at the start of the field.

This commit is contained in:
John Preston
2018-05-27 13:48:30 +03:00
parent dfbe11efdb
commit f334e2d0f4
2 changed files with 10 additions and 0 deletions

View File

@@ -1122,6 +1122,7 @@ InputField::InputField(
connect(_inner->document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(onDocumentContentsChange(int,int,int)));
connect(_inner, SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool)));
connect(_inner, SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool)));
connect(_inner, SIGNAL(cursorPositionChanged()), this, SLOT(onCursorPositionChanged()));
if (App::wnd()) connect(_inner, SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));
const auto bar = _inner->verticalScrollBar();
@@ -1979,6 +1980,14 @@ void InputField::onDocumentContentsChange(
}
}
void InputField::onCursorPositionChanged() {
auto cursor = textCursor();
if (!cursor.hasSelection() && !cursor.position()) {
cursor.setCharFormat(_defaultCharFormat);
setTextCursor(cursor);
}
}
void InputField::chopByMaxLength(int insertPosition, int insertLength) {
Expects(_correcting);