Modify double click check to allow some fuzz in the pointer placement, as is done in Tracker. BTextView likely needs a similar adjustment.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30147 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -33,6 +33,8 @@ struct track_data {
|
|||||||
bigtime_t last_click_time;
|
bigtime_t last_click_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const float kDoubleClickTresh = 6;
|
||||||
|
|
||||||
static property_info sProperties[] = {
|
static property_info sProperties[] = {
|
||||||
{ "Item", { B_COUNT_PROPERTIES, 0 }, { B_DIRECT_SPECIFIER, 0 },
|
{ "Item", { B_COUNT_PROPERTIES, 0 }, { B_DIRECT_SPECIFIER, 0 },
|
||||||
"Returns the number of BListItems currently in the list.", 0, { B_INT32_TYPE }
|
"Returns the number of BListItems currently in the list.", 0, { B_INT32_TYPE }
|
||||||
@@ -311,14 +313,24 @@ BListView::MouseDown(BPoint point)
|
|||||||
|
|
||||||
// If the user double (or more) clicked within the current selection,
|
// If the user double (or more) clicked within the current selection,
|
||||||
// we don't change the selection but invoke the selection.
|
// we don't change the selection but invoke the selection.
|
||||||
bigtime_t clickSpeed = 0;
|
// TODO: move this code someplace where it can be shared everywhere
|
||||||
get_click_speed(&clickSpeed);
|
// instead of every class having to reimplement it, once some sane
|
||||||
bool multipleClick = system_time() - fTrack->last_click_time < clickSpeed
|
// API for it is decided.
|
||||||
&& point == fTrack->drag_start;
|
BPoint delta = point - fTrack->drag_start;
|
||||||
|
bigtime_t sysTime;
|
||||||
|
Window()->CurrentMessage()->FindInt64("when", &sysTime);
|
||||||
if (multipleClick && index >= fFirstSelected && index <= fLastSelected) {
|
bigtime_t timeDelta = sysTime - fTrack->last_click_time;
|
||||||
printf("Invoking item %ld\n", index);
|
bigtime_t doubleClickSpeed;
|
||||||
|
get_click_speed(&doubleClickSpeed);
|
||||||
|
bool doubleClick = false;
|
||||||
|
|
||||||
|
if (timeDelta < doubleClickSpeed
|
||||||
|
&& fabs(delta.x) < kDoubleClickTresh
|
||||||
|
&& fabs(delta.y) < kDoubleClickTresh)
|
||||||
|
doubleClick = true;
|
||||||
|
|
||||||
|
if (doubleClick && index >= fFirstSelected && index <= fLastSelected) {
|
||||||
|
fTrack->drag_start.Set(LONG_MAX, LONG_MAX);
|
||||||
Invoke();
|
Invoke();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -326,7 +338,7 @@ BListView::MouseDown(BPoint point)
|
|||||||
int32 modifiers;
|
int32 modifiers;
|
||||||
message->FindInt32("modifiers", &modifiers);
|
message->FindInt32("modifiers", &modifiers);
|
||||||
|
|
||||||
if (!multipleClick) {
|
if (!doubleClick) {
|
||||||
fTrack->drag_start = point;
|
fTrack->drag_start = point;
|
||||||
fTrack->last_click_time = system_time();
|
fTrack->last_click_time = system_time();
|
||||||
fTrack->item_index = index;
|
fTrack->item_index = index;
|
||||||
|
|||||||
Reference in New Issue
Block a user