sneedmc/launcher/ui/widgets/FocusLineEdit.cpp

26 lines
509 B
C++
Raw Normal View History

#include "FocusLineEdit.h"
#include <QDebug>
FocusLineEdit::FocusLineEdit(QWidget *parent) : QLineEdit(parent)
{
2018-07-15 12:51:05 +00:00
_selectOnMousePress = false;
}
void FocusLineEdit::focusInEvent(QFocusEvent *e)
{
2018-07-15 12:51:05 +00:00
QLineEdit::focusInEvent(e);
selectAll();
_selectOnMousePress = true;
}
void FocusLineEdit::mousePressEvent(QMouseEvent *me)
{
2018-07-15 12:51:05 +00:00
QLineEdit::mousePressEvent(me);
if (_selectOnMousePress)
{
selectAll();
_selectOnMousePress = false;
}
qDebug() << selectedText();
}