Esempio n. 1
0
void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent)
{
    if (mouseEvent.getButton() != gcn::MouseEvent::LEFT)
        return;

    // Make table selection update on drag
    const int x = std::max(0, mouseEvent.getX());
    const int y = std::max(0, mouseEvent.getY());

    setSelectedRow(getRowForY(y));
    setSelectedColumn(getColumnForX(x));
}
Esempio n. 2
0
// -- MouseListener notifications
void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
{
    if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
    {
        int row = getRowForY(mouseEvent.getY());
        int column = getColumnForX(mouseEvent.getX());

        if (row > -1 && column > -1 &&
            row < mModel->getRows() && column < mModel->getColumns())
        {
            mSelectedColumn = column;
            mSelectedRow = row;
        }

        distributeActionEvent();
    }
}
Esempio n. 3
0
gcn::Widget *GuiTable::getWidgetAt(int x, int y) const
{
    int row = getRowForY(y);
    int column = getColumnForX(x);

    if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y))
        return mTopWidget;

    if (row > -1 && column > -1)
    {
        gcn::Widget *w = mModel->getElementAt(row, column);
        if (w && w->isFocusable())
            return w;
        else
            return NULL; // Grab the event locally
    }
    else
        return NULL;
}
Esempio n. 4
0
// -- MouseListener notifications
void GuiTable::mousePressed(MouseEvent& event)
{
    if (!mSelectable)
        return;

    if (event.getButton() == MouseButton::LEFT)
    {
        const int row = getRowForY(event.getY());
        const int column = getColumnForX(event.getX());

        if (row > -1 && column > -1 &&
            row < mModel->getRows() && column < mModel->getColumns())
        {
            mSelectedColumn = column;
            mSelectedRow = row;
            event.consume();
        }

        distributeActionEvent();
    }
}