From 04cec2bbbd023afca2038289103ad9bf921dce7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 14 Mar 2006 21:38:11 +0000 Subject: [PATCH] Implemented invocation on double click. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16799 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/ListView.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index 397c4b3744..460d657789 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -280,14 +280,20 @@ BListView::MouseDown(BPoint point) } BMessage *message = Looper()->CurrentMessage(); + int32 index = IndexOf(point); + + // If the user double (or more) clicked within the current selection, + // we don't change the selection but invoke the selection. int32 clicks; + if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1 + && index >= fFirstSelected && index <= fLastSelected) { + Invoke(); + return; + } + int32 modifiers; - - message->FindInt32("clicks", &clicks); message->FindInt32("modifiers", &modifiers); - int index = IndexOf(point); - fTrack->drag_start = point; fTrack->item_index = index; fTrack->was_selected = index >= 0 ? ItemAt(index)->IsSelected() : false; @@ -303,19 +309,17 @@ BListView::MouseDown(BPoint point) if (modifiers & B_SHIFT_KEY) { // toggle selection state of clicked item (like in Tracker) // toggle selection state of clicked item - if (clicks == 1) { - if (ItemAt(index)->IsSelected()) - Deselect(index); - else - Select(index, true); - } + if (ItemAt(index)->IsSelected()) + Deselect(index); + else + Select(index, true); } else { Select(index); } } } else { // toggle selection state of clicked item - if ((modifiers & B_SHIFT_KEY) && ItemAt(index)->IsSelected() && clicks == 1) + if ((modifiers & B_SHIFT_KEY) && ItemAt(index)->IsSelected()) Deselect(index); else Select(index); @@ -828,6 +832,9 @@ BListView::CurrentSelection(int32 index) const status_t BListView::Invoke(BMessage *message) { + // Note, this is more or less a copy of BControl::Invoke() and should + // stay that way (ie. changes done there should be adopted here) + bool notify = false; uint32 kind = InvokeKind(¬ify); @@ -861,8 +868,7 @@ BListView::Invoke(BMessage *message) if (message) err = BInvoker::Invoke(&clone); -// TODO: assynchronous messaging -// SendNotices(kind, &clone); + SendNotices(kind, &clone); return err; }