Clear text selection when focus is lost

fixes #409
remotes/origin/HEAD
Konstantinos Sideris 6 years ago
parent 7a288cc2cb
commit c9427c7f17
  1. 11
      src/timeline/TimelineItem.cpp
  2. 1
      src/timeline/TimelineItem.h

@ -69,7 +69,6 @@ TextLabel::TextLabel(const QString &text, QWidget *parent)
&TextLabel::adjustHeight); &TextLabel::adjustHeight);
document()->setDocumentMargin(0); document()->setDocumentMargin(0);
setFocusPolicy(Qt::NoFocus);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
setFixedHeight(0); setFixedHeight(0);
@ -94,6 +93,16 @@ TextLabel::TextLabel(const QString &text, QWidget *parent)
}); });
} }
void
TextLabel::focusOutEvent(QFocusEvent *e)
{
QTextBrowser::focusOutEvent(e);
QTextCursor cursor = textCursor();
cursor.clearSelection();
setTextCursor(cursor);
}
void void
TextLabel::mousePressEvent(QMouseEvent *e) TextLabel::mousePressEvent(QMouseEvent *e)
{ {

@ -110,6 +110,7 @@ public:
protected: protected:
void mousePressEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override;
void focusOutEvent(QFocusEvent* e) override;
private slots: private slots:
void adjustHeight(const QSizeF &size) { setFixedHeight(size.height()); } void adjustHeight(const QSizeF &size) { setFixedHeight(size.height()); }

Loading…
Cancel
Save