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)); }
// -- 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(); } }
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; }
// -- 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(); } }