void DisplayDirector::MouseDown(int x, int y) { BPoint mousePoint(x, y); View* view = WindowView(); // hit the hotspot if (hotspot && hotspot->ContainsPoint(ViewToDoc(mousePoint))) hotspot->Clicked(this); // extend the selection else if ((view->CurModifiers() & B_SHIFT_KEY) != 0) ExtendSelection(); // promote or drag the selection else if (selection && selection->ContainsPoint(ViewToDoc(mousePoint))) { if (view->CurClicks() > 1) { StartRefreshCycle(); selection->Promote(this); FinishRefreshCycle(); ExtendSelection(); } else DragSelection(mousePoint); } // otherwise find a new selection else { if (DocRect().Contains(mousePoint)) FindSelection(); else SetSelection(NULL); } }
void DisplayDirector::DragSelection(BPoint startPoint) { if (selection == NULL) return; View* view = WindowView(); BPoint lastPoint = ViewToDoc(startPoint); bool scrolling = false; bool wasRightButton = false; bool optionDown = false; while (true) { // get the mouse point and check if moved/finished BPoint point = view->GetMousePoint(); int buttons = view->GetMouseButtons(); if (buttons == 0) break; wasRightButton = ((buttons & (B_SECONDARY_MOUSE_BUTTON | B_TERTIARY_MOUSE_BUTTON)) != 0); optionDown = ((view->CurModifiers() & B_OPTION_KEY) != 0); scrolling |= Autoscroll(point); point = ViewToDoc(point); if (point == lastPoint && !scrolling) { view->MouseTrackingPause(); continue; } // change the destination Destination* newDestination = NULL; if (!selection->ContainsPoint(point)) { FindDestinationContext destContext(selection, point.x, point.y); newDestination = docDisplayNode->BlockFindDestination(&destContext); } if (newDestination != destination) { StartRefreshCycle(); SetDestination(newDestination); scrolling = DoScrollStep(); FinishRefreshCycle(); } else scrolling = DoScrollStep(); lastPoint = point; } // do the move/copy if (destination) { // figure out if it's a move or a copy bool doing = true; bool copying = false; /*** if (wasRightButton) { BPopUpMenu* menu = new BPopUpMenu("Move/Copy"); BMenuItem* moveItem = new BMenuItem("Move", NULL); menu->AddItem(moveItem); BMenuItem* copyItem = new BMenuItem("Copy", NULL); menu->AddItem(copyItem); BMenuItem* chosenItem = menu->Go(ConvertToScreen(DocToView(lastPoint)), false, true); copying = (chosenItem == copyItem); if (chosenItem == NULL) doing = false; delete menu; } else if (optionDown) copying = true; ***/ if (optionDown) copying = true; if (doing) { StartRefreshCycle(); // do the move or copy Action* moveAction = NULL; if (copying) moveAction = destination->GetCopyAction(); else moveAction = destination->GetMoveAction(); if (moveAction) DoAction(moveAction); SetDestination(NULL); FinishRefreshCycle(); } else SetDestination(NULL); } }