void BaseTab::OnMouseReleased(const view::MouseEvent& event) { if(!controller()) { return; } // Notify the drag helper that we're done with any potential drag operations. // Clean up the drag helper, which is re-created on the next mouse press. // In some cases, ending the drag will schedule the tab for destruction; if // so, bail immediately, since our members are already dead and we shouldn't // do anything else except drop the tab where it is. if(controller()->EndDrag(false)) { return; } // Close tab on middle click, but only if the button is released over the tab // (normal windows behavior is to discard presses of a UI element where the // releases happen off the element). if(event.IsMiddleMouseButton()) { if(HitTest(event.location())) { controller()->CloseTab(this); } else if(closing_) { // We're animating closed and a middle mouse button was pushed on us but // we don't contain the mouse anymore. We assume the user is clicking // quicker than the animation and we should close the tab that falls under // the mouse. BaseTab* closest_tab = controller()->GetTabAt(this, event.location()); if(closest_tab) { controller()->CloseTab(closest_tab); } } } else if(event.IsOnlyLeftMouseButton() && !event.IsShiftDown() && !event.IsControlDown()) { // If the tab was already selected mouse pressed doesn't change the // selection. Reset it now to handle the case where multiple tabs were // selected. controller()->SelectTab(this); } }
bool BaseTab::OnMousePressed(const view::MouseEvent& event) { if(!controller()) { return false; } if(event.IsOnlyLeftMouseButton()) { if(event.IsShiftDown() && event.IsControlDown()) { controller()->AddSelectionFromAnchorTo(this); } else if(event.IsShiftDown()) { controller()->ExtendSelectionTo(this); } else if(event.IsControlDown()) { controller()->ToggleSelected(this); if(!IsSelected()) { // Don't allow dragging non-selected tabs. return false; } } else if(!IsSelected()) { controller()->SelectTab(this); } else if(IsActive()) { controller()->ClickActiveTab(this); } controller()->MaybeStartDrag(this, event); } return true; }