Make BListView's doubleclick handling a bit more sane. Should fix ticket #3724.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30131 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2009-04-12 03:28:39 +00:00
parent fcdaa0c79d
commit 11c511b999
+17 -8
View File
@@ -30,6 +30,7 @@ struct track_data {
int32 item_index; int32 item_index;
bool was_selected; bool was_selected;
bool try_drag; bool try_drag;
bigtime_t last_click_time;
}; };
static property_info sProperties[] = { static property_info sProperties[] = {
@@ -310,20 +311,28 @@ 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.
int32 clicks; bigtime_t clickSpeed = 0;
if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1 get_click_speed(&clickSpeed);
&& index >= fFirstSelected && index <= fLastSelected) { bool multipleClick = system_time() - fTrack->last_click_time < clickSpeed
&& point == fTrack->drag_start;
if (multipleClick && index >= fFirstSelected && index <= fLastSelected) {
printf("Invoking item %ld\n", index);
Invoke(); Invoke();
return; return;
} }
int32 modifiers; int32 modifiers;
message->FindInt32("modifiers", &modifiers); message->FindInt32("modifiers", &modifiers);
fTrack->drag_start = point; if (!multipleClick) {
fTrack->item_index = index; fTrack->drag_start = point;
fTrack->was_selected = index >= 0 ? ItemAt(index)->IsSelected() : false; fTrack->last_click_time = system_time();
fTrack->try_drag = true; fTrack->item_index = index;
fTrack->was_selected = index >= 0 ? ItemAt(index)->IsSelected() : false;
fTrack->try_drag = true;
}
if (index > -1) { if (index > -1) {
if (fListType == B_MULTIPLE_SELECTION_LIST) { if (fListType == B_MULTIPLE_SELECTION_LIST) {