Skip to content
Permalink
Browse files

selectAll if requested on mouse release

because otherwise the mouse event makes the selectAll useless if it's done on focusEvent
  • Loading branch information
signedav committed Oct 10, 2018
1 parent fbbb320 commit d3c861e744cefd4657e8a4d4219f634a8cd51d58
@@ -268,6 +268,8 @@ Will select all text when this widget receives the focus.
protected:
virtual void focusInEvent( QFocusEvent *e );

virtual void mouseReleaseEvent( QMouseEvent *e );


};

@@ -90,6 +90,16 @@ void QgsFilterLineEdit::focusInEvent( QFocusEvent *e )
if ( e->reason() == Qt::MouseFocusReason && ( isNull() || mSelectOnFocus ) )
{
mFocusInEvent = true;
mWaitingForMouseRelease = true;
}
}

void QgsFilterLineEdit::mouseReleaseEvent( QMouseEvent *e )
{
QLineEdit::mouseReleaseEvent( e );
if ( mWaitingForMouseRelease )
{
mWaitingForMouseRelease = false;
selectAll();
}
}
@@ -265,6 +265,7 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit

protected:
void focusInEvent( QFocusEvent *e ) override;
void mouseReleaseEvent( QMouseEvent *e ) override;

private slots:
void onTextChanged( const QString &text );
@@ -286,6 +287,7 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
QString mDefaultValue;
QString mStyleSheet;
bool mFocusInEvent = false;
bool mWaitingForMouseRelease = false;
bool mSelectOnFocus = false;

QgsAnimatedIcon *mBusySpinnerAnimatedIcon = nullptr;

0 comments on commit d3c861e

Please sign in to comment.
You can’t perform that action at this time.