* Added a _MouseDistanceSinceLastClick() that returns the square of the pixel
distance of the last click and the point passed in. * Use this one to delay starting of character wide selections. * Also, treat double/triple clicks as single clicks if the mouse moved too far. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28132 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1802,6 +1802,15 @@ TermView::_WritePTY(const char* text, int32 numBytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Returns the square of the actual pixel distance between both points
|
||||||
|
float
|
||||||
|
TermView::_MouseDistanceSinceLastClick(BPoint where)
|
||||||
|
{
|
||||||
|
return (fLastClickPoint.x - where.x) * (fLastClickPoint.x - where.x)
|
||||||
|
+ (fLastClickPoint.y - where.y) * (fLastClickPoint.y - where.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::MouseDown(BPoint where)
|
TermView::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
@@ -1816,6 +1825,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
// paste button
|
// paste button
|
||||||
if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) {
|
if ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0) {
|
||||||
Paste(gMouseClipboard);
|
Paste(gMouseClipboard);
|
||||||
|
fLastClickPoint = where;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1850,14 +1860,12 @@ TermView::MouseDown(BPoint where)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If mouse has a lot of movement, disable double/triple click.
|
// If mouse has moved too much, disable double/triple click.
|
||||||
/*BPoint inPoint = fClickPoint - where;
|
if (_MouseDistanceSinceLastClick(where) > 8)
|
||||||
if (abs((int)inPoint.x) > 16 || abs((int)inPoint.y) > 16)
|
|
||||||
clicks = 1;
|
clicks = 1;
|
||||||
*/
|
|
||||||
|
|
||||||
SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS,
|
SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS,
|
||||||
B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS);
|
B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS);
|
||||||
|
|
||||||
TermPos clickPos = _ConvertToTerminal(where);
|
TermPos clickPos = _ConvertToTerminal(where);
|
||||||
|
|
||||||
@@ -1876,7 +1884,7 @@ TermView::MouseDown(BPoint where)
|
|||||||
|
|
||||||
switch (clicks) {
|
switch (clicks) {
|
||||||
case 1:
|
case 1:
|
||||||
fMouseTracking = true;
|
fCheckMouseTracking = true;
|
||||||
fSelectGranularity = SELECT_CHARS;
|
fSelectGranularity = SELECT_CHARS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1892,17 +1900,19 @@ TermView::MouseDown(BPoint where)
|
|||||||
fSelectGranularity = SELECT_LINES;
|
fSelectGranularity = SELECT_LINES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BView::MouseDown(where);
|
fLastClickPoint = where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
||||||
{
|
{
|
||||||
BView::MouseMoved(where, transit, message);
|
if (fCheckMouseTracking) {
|
||||||
|
if (_MouseDistanceSinceLastClick(where) > 9)
|
||||||
|
fMouseTracking = true;
|
||||||
|
}
|
||||||
if (!fMouseTracking)
|
if (!fMouseTracking)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1962,7 +1972,7 @@ TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message)
|
|||||||
void
|
void
|
||||||
TermView::MouseUp(BPoint where)
|
TermView::MouseUp(BPoint where)
|
||||||
{
|
{
|
||||||
BView::MouseUp(where);
|
fCheckMouseTracking = false;
|
||||||
fMouseTracking = false;
|
fMouseTracking = false;
|
||||||
|
|
||||||
if (fAutoScrollRunner != NULL) {
|
if (fAutoScrollRunner != NULL) {
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ private:
|
|||||||
// void _ConfirmString(const char *, int32);
|
// void _ConfirmString(const char *, int32);
|
||||||
|
|
||||||
// selection
|
// selection
|
||||||
|
float _MouseDistanceSinceLastClick(BPoint where);
|
||||||
void _Select(TermPos start, TermPos end, bool inclusive,
|
void _Select(TermPos start, TermPos end, bool inclusive,
|
||||||
bool setInitialSelection);
|
bool setInitialSelection);
|
||||||
void _ExtendSelection(TermPos, bool inclusive,
|
void _ExtendSelection(TermPos, bool inclusive,
|
||||||
@@ -242,7 +243,9 @@ private:
|
|||||||
TermPos fInitialSelectionStart;
|
TermPos fInitialSelectionStart;
|
||||||
TermPos fInitialSelectionEnd;
|
TermPos fInitialSelectionEnd;
|
||||||
bool fMouseTracking;
|
bool fMouseTracking;
|
||||||
|
bool fCheckMouseTracking;
|
||||||
int fSelectGranularity;
|
int fSelectGranularity;
|
||||||
|
BPoint fLastClickPoint;
|
||||||
|
|
||||||
// Input Method parameter.
|
// Input Method parameter.
|
||||||
int fIMViewPtr;
|
int fIMViewPtr;
|
||||||
|
|||||||
Reference in New Issue
Block a user