mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Triple-clicking now also checks for distance between clicks to prevent unwanted selection.
This commit is contained in:
parent
423ef19c8f
commit
49398300d6
2 changed files with 13 additions and 3 deletions
|
@ -899,6 +899,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
if (wordStart < this->selection_.start.charIndex &&
|
if (wordStart < this->selection_.start.charIndex &&
|
||||||
!this->dCSelection_.selectingRight) {
|
!this->dCSelection_.selectingRight) {
|
||||||
this->dCSelection_.selectingLeft = true;
|
this->dCSelection_.selectingLeft = true;
|
||||||
|
// Ensure that the original word stays selected(Edge case)
|
||||||
if (wordStart > this->dCSelection_.originalEnd) {
|
if (wordStart > this->dCSelection_.originalEnd) {
|
||||||
this->setSelection(this->dCSelection_.origStartItem,
|
this->setSelection(this->dCSelection_.origStartItem,
|
||||||
newEnd);
|
newEnd);
|
||||||
|
@ -909,6 +910,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
} else if (wordEnd > this->selection_.end.charIndex &&
|
} else if (wordEnd > this->selection_.end.charIndex &&
|
||||||
!this->dCSelection_.selectingLeft) {
|
!this->dCSelection_.selectingLeft) {
|
||||||
this->dCSelection_.selectingRight = true;
|
this->dCSelection_.selectingRight = true;
|
||||||
|
// Ensure that the original word stays selected(Edge case)
|
||||||
if (wordEnd < this->dCSelection_.originalStart) {
|
if (wordEnd < this->dCSelection_.originalStart) {
|
||||||
this->setSelection(newStart,
|
this->setSelection(newStart,
|
||||||
this->dCSelection_.origEndItem);
|
this->dCSelection_.origEndItem);
|
||||||
|
@ -1068,15 +1070,21 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
// check if mouse was pressed
|
// check if mouse was pressed
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
this->isDoubleClick_ = this->dCSelection_.selectingLeft =
|
this->dCSelection_.selectingLeft = this->dCSelection_.selectingRight =
|
||||||
this->dCSelection_.selectingRight = false;
|
false;
|
||||||
if (this->isMouseDown_) {
|
if (this->isMouseDown_ || this->isDoubleClick_) {
|
||||||
this->isMouseDown_ = false;
|
this->isMouseDown_ = false;
|
||||||
|
this->isDoubleClick_ = false;
|
||||||
|
|
||||||
if (fabsf(distanceBetweenPoints(this->lastPressPosition_,
|
if (fabsf(distanceBetweenPoints(this->lastPressPosition_,
|
||||||
event->screenPos())) > 15.f) {
|
event->screenPos())) > 15.f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Was actually not a wanted triple-click
|
||||||
|
if (fabsf(distanceBetweenPoints(this->lastDClickPosition_,
|
||||||
|
event->screenPos())) > 10.f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1286,6 +1294,7 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
|
||||||
const MessageLayoutElement *hoverLayoutElement =
|
const MessageLayoutElement *hoverLayoutElement =
|
||||||
layout->getElementAt(relativePos);
|
layout->getElementAt(relativePos);
|
||||||
|
this->lastDClickPosition_ = event->screenPos();
|
||||||
|
|
||||||
if (hoverLayoutElement == nullptr) {
|
if (hoverLayoutElement == nullptr) {
|
||||||
// Possibility for triple click which doesn't have to be over an
|
// Possibility for triple click which doesn't have to be over an
|
||||||
|
|
|
@ -155,6 +155,7 @@ private:
|
||||||
DoubleClickSelection dCSelection_;
|
DoubleClickSelection dCSelection_;
|
||||||
QPointF lastPressPosition_;
|
QPointF lastPressPosition_;
|
||||||
QPointF lastRightPressPosition_;
|
QPointF lastRightPressPosition_;
|
||||||
|
QPointF lastDClickPosition_;
|
||||||
QTimer *clickTimer_;
|
QTimer *clickTimer_;
|
||||||
|
|
||||||
Selection selection_;
|
Selection selection_;
|
||||||
|
|
Loading…
Reference in a new issue