Exemple #1
0
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 DesktopWindowManager::HandleMouseEvent(
            view::Widget* widget, const view::MouseEvent& event)
        {
            if(mouse_capture_)
            {
                view::MouseEvent translated(event, widget->GetRootView(),
                    mouse_capture_->GetRootView());
                mouse_capture_->OnMouseEvent(translated);
                return true;
            }

            if(event.type() == ui::ET_MOUSE_PRESSED)
            {
                ActivateWidgetAtLocation(widget, event.location());
            }
            else if(event.type()==ui::ET_MOUSEWHEEL && active_widget_)
            {
                return active_widget_->OnMouseEvent(event);
            }

            if(window_controller_.get())
            {
                if(!window_controller_->OnMouseEvent(event))
                {
                    ReleaseMouseCapture();
                    window_controller_.reset();
                }
                return true;
            }

            return false;
        }