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 &&
|
||||
!this->dCSelection_.selectingRight) {
|
||||
this->dCSelection_.selectingLeft = true;
|
||||
// Ensure that the original word stays selected(Edge case)
|
||||
if (wordStart > this->dCSelection_.originalEnd) {
|
||||
this->setSelection(this->dCSelection_.origStartItem,
|
||||
newEnd);
|
||||
|
@ -909,6 +910,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
} else if (wordEnd > this->selection_.end.charIndex &&
|
||||
!this->dCSelection_.selectingLeft) {
|
||||
this->dCSelection_.selectingRight = true;
|
||||
// Ensure that the original word stays selected(Edge case)
|
||||
if (wordEnd < this->dCSelection_.originalStart) {
|
||||
this->setSelection(newStart,
|
||||
this->dCSelection_.origEndItem);
|
||||
|
@ -1068,15 +1070,21 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
|||
{
|
||||
// check if mouse was pressed
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
this->isDoubleClick_ = this->dCSelection_.selectingLeft =
|
||||
this->dCSelection_.selectingRight = false;
|
||||
if (this->isMouseDown_) {
|
||||
this->dCSelection_.selectingLeft = this->dCSelection_.selectingRight =
|
||||
false;
|
||||
if (this->isMouseDown_ || this->isDoubleClick_) {
|
||||
this->isMouseDown_ = false;
|
||||
this->isDoubleClick_ = false;
|
||||
|
||||
if (fabsf(distanceBetweenPoints(this->lastPressPosition_,
|
||||
event->screenPos())) > 15.f) {
|
||||
return;
|
||||
}
|
||||
// Was actually not a wanted triple-click
|
||||
if (fabsf(distanceBetweenPoints(this->lastDClickPosition_,
|
||||
event->screenPos())) > 10.f) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -1286,6 +1294,7 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
|
||||
const MessageLayoutElement *hoverLayoutElement =
|
||||
layout->getElementAt(relativePos);
|
||||
this->lastDClickPosition_ = event->screenPos();
|
||||
|
||||
if (hoverLayoutElement == nullptr) {
|
||||
// Possibility for triple click which doesn't have to be over an
|
||||
|
|
|
@ -155,6 +155,7 @@ private:
|
|||
DoubleClickSelection dCSelection_;
|
||||
QPointF lastPressPosition_;
|
||||
QPointF lastRightPressPosition_;
|
||||
QPointF lastDClickPosition_;
|
||||
QTimer *clickTimer_;
|
||||
|
||||
Selection selection_;
|
||||
|
|
Loading…
Reference in a new issue