* Fix regression spotted by Humdinger. Emulate right click dragging like it
used to work before, i.e right mouse button dragging works and the context menu shows on mouse up if not dragged. I guess that at some point we'll rethink all the mouse gestures we support and maybe simplify a bit, like dropping long click support (as an emulated right button), and possibly separating some features via user settings if needed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41929 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
58e371f5a5
commit
f2068166ad
@ -6,7 +6,7 @@
|
||||
/*!
|
||||
\class LongAndDragTrackingFilter
|
||||
\brief A simple long mouse down and drag detection filter
|
||||
*
|
||||
*
|
||||
* A simple mouse filter that detects long clicks and pointer drags.
|
||||
* A long click message is sent when the mouse button is kept down
|
||||
* for a duration longer than a given threshold while the pointer stays
|
||||
@ -18,8 +18,8 @@
|
||||
* the moment of the click. The drag message is ready to use with the
|
||||
* be/haiku drag and drop API cf. comment in code.
|
||||
*
|
||||
* Note: for simplicity and current needs (Tracker), only the left mouse
|
||||
* button is tracked.
|
||||
* Current limitation: A long mouse down or a drag can be detected for
|
||||
* any mouse button, but any released button cancels the tracking.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -77,8 +77,7 @@ LongAndDragTrackingFilter::Filter(BMessage* message, BHandler** target)
|
||||
|
||||
message->FindInt32("buttons", (int32*)&fClickButtons);
|
||||
|
||||
if ((fClickButtons & B_PRIMARY_MOUSE_BUTTON)
|
||||
== B_PRIMARY_MOUSE_BUTTON) {
|
||||
if (fClickButtons != 0) {
|
||||
|
||||
BView* targetView = dynamic_cast<BView*>(*target);
|
||||
if (targetView != NULL)
|
||||
@ -97,14 +96,15 @@ LongAndDragTrackingFilter::Filter(BMessage* message, BHandler** target)
|
||||
|
||||
case B_MOUSE_UP:
|
||||
_StopTracking();
|
||||
message->AddInt32("last_buttons", (int32)fClickButtons);
|
||||
return B_DISPATCH_MESSAGE;
|
||||
|
||||
case B_MOUSE_MOVED:
|
||||
{
|
||||
if (fMessageRunner != NULL) {
|
||||
if (fMessageRunner != NULL) {
|
||||
BPoint where;
|
||||
message->FindPoint("be:view_where", &where);
|
||||
|
||||
|
||||
BPoint delta(fClickPoint - where);
|
||||
float squaredDelta = (delta.x * delta.x) + (delta.y * delta.y);
|
||||
|
||||
@ -114,7 +114,7 @@ LongAndDragTrackingFilter::Filter(BMessage* message, BHandler** target)
|
||||
// name it "be:view_where" since BView::DragMessage
|
||||
// positions the dragging frame/bitmap by retrieving
|
||||
// the current message and reading that field
|
||||
dragMessage.AddInt32("buttons", fClickButtons);
|
||||
dragMessage.AddInt32("buttons", (int32)fClickButtons);
|
||||
BMessenger messenger(*target);
|
||||
messenger.SendMessage(&dragMessage);
|
||||
|
||||
|
@ -2159,17 +2159,17 @@ BPoseView::MessageReceived(BMessage *message)
|
||||
case kMiniIconMode:
|
||||
SetViewMode(message->what);
|
||||
break;
|
||||
|
||||
|
||||
case kMsgMouseDragged:
|
||||
MouseDragged(message);
|
||||
break;
|
||||
|
||||
|
||||
case kMsgMouseLongDown:
|
||||
MouseLongDown(message);
|
||||
break;
|
||||
|
||||
|
||||
case B_MOUSE_IDLE:
|
||||
MouseIdle(message);
|
||||
MouseIdle(message);
|
||||
break;
|
||||
|
||||
case B_SELECT_ALL:
|
||||
@ -6707,7 +6707,7 @@ BPoseView::MouseMoved(BPoint mouseLoc, uint32 moveCode, const BMessage *message)
|
||||
{
|
||||
if (fSelectionRectInfo.isDragging)
|
||||
_UpdateSelectionRect(mouseLoc);
|
||||
|
||||
|
||||
if (!fDropEnabled || !message)
|
||||
return;
|
||||
|
||||
@ -6737,7 +6737,7 @@ BPoseView::MouseMoved(BPoint mouseLoc, uint32 moveCode, const BMessage *message)
|
||||
fDropTarget = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6745,7 +6745,9 @@ void
|
||||
BPoseView::MouseDragged(const BMessage *message)
|
||||
{
|
||||
BPoint where;
|
||||
if (message->FindPoint("be:view_where", &where) != B_OK)
|
||||
uint32 buttons = 0;
|
||||
if (message->FindPoint("be:view_where", &where) != B_OK
|
||||
|| message->FindInt32("buttons", (int32*)&buttons) != B_OK)
|
||||
return;
|
||||
|
||||
bool extendSelection = (modifiers() & B_COMMAND_KEY) && fMultipleSelection;
|
||||
@ -6754,8 +6756,8 @@ BPoseView::MouseDragged(const BMessage *message)
|
||||
BPose* pose = FindPose(where, &index);
|
||||
if (pose != NULL)
|
||||
DragSelectedPoses(pose, where);
|
||||
else
|
||||
_BeginSelectionRect(where, extendSelection);
|
||||
else if (buttons == B_PRIMARY_MOUSE_BUTTON)
|
||||
_BeginSelectionRect(where, extendSelection);
|
||||
}
|
||||
|
||||
|
||||
@ -6780,7 +6782,7 @@ BPoseView::MouseIdle(const BMessage *message)
|
||||
|
||||
if (buttons == 0 || window == NULL)
|
||||
return;
|
||||
|
||||
|
||||
if (fDropTarget != NULL) {
|
||||
window->DragStart(message);
|
||||
FrameForPose(fDropTarget, true, &fStartFrame);
|
||||
@ -6808,35 +6810,13 @@ BPoseView::MouseDown(BPoint where)
|
||||
|
||||
MakeFocus();
|
||||
|
||||
// "right" mouse button handling for context-sensitive menus
|
||||
uint32 buttons = (uint32)window->CurrentMessage()->FindInt32("buttons");
|
||||
uint32 modifs = modifiers();
|
||||
|
||||
bool showContext = true;
|
||||
if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0)
|
||||
showContext = (modifs & B_CONTROL_KEY) != 0;
|
||||
|
||||
if (showContext) {
|
||||
int32 index;
|
||||
BPose *pose = FindPose(where, &index);
|
||||
if (!pose) {
|
||||
ShowContextMenu(where);
|
||||
return;
|
||||
}
|
||||
if (!pose->IsSelected()) {
|
||||
ClearSelection();
|
||||
pose->Select(true);
|
||||
fSelectionList->AddItem(pose);
|
||||
DrawPose(pose, index, false);
|
||||
}
|
||||
ShowContextMenu(where);
|
||||
}
|
||||
|
||||
bool extendSelection = (modifs & B_COMMAND_KEY) && fMultipleSelection;
|
||||
|
||||
CommitActivePose();
|
||||
|
||||
// see if mouse down occurred within a pose
|
||||
int32 index;
|
||||
BPose *pose = FindPose(where, &index);
|
||||
if (pose) {
|
||||
@ -6853,10 +6833,16 @@ BPoseView::MouseDown(BPoint where)
|
||||
|
||||
window->Activate();
|
||||
window->UpdateIfNeeded();
|
||||
|
||||
|
||||
// only clear selection if we are not extending it
|
||||
if (!extendSelection || !fSelectionRectEnabled || !fMultipleSelection)
|
||||
ClearSelection();
|
||||
|
||||
// show desktop context menu
|
||||
if (buttons == B_SECONDARY_MOUSE_BUTTON
|
||||
|| (modifs & B_CONTROL_KEY) != 0) {
|
||||
ShowContextMenu(where);
|
||||
}
|
||||
}
|
||||
|
||||
if (fSelectionChangedHook)
|
||||
@ -6874,6 +6860,26 @@ BPoseView::MouseUp(BPoint where)
|
||||
BPose* pose = FindPose(where, &index);
|
||||
if (pose != NULL && fAllowPoseEditing)
|
||||
pose->MouseUp(BPoint(0, index * fListElemHeight), this, where, index);
|
||||
|
||||
uint32 lastButtons = Window()->CurrentMessage()->FindInt32("last_buttons");
|
||||
// this handy field has been added by the tracking filter.
|
||||
// we need lastButtons for right button mouse-up tracking,
|
||||
// because there's currently no way to know wich buttons were
|
||||
// released in BView::MouseUp (unlike BView::KeyUp)
|
||||
|
||||
// Showing the pose context menu is done on mouse up (or long click)
|
||||
// to make right button dragging possible
|
||||
if (pose != NULL && pose == fLastClickedPose
|
||||
&& (lastButtons == B_SECONDARY_MOUSE_BUTTON
|
||||
|| (modifiers() & B_CONTROL_KEY) != 0)) {
|
||||
if (!pose->IsSelected()) {
|
||||
ClearSelection();
|
||||
pose->Select(true);
|
||||
fSelectionList->AddItem(pose);
|
||||
DrawPose(pose, index, false);
|
||||
}
|
||||
ShowContextMenu(where);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user