nodeview: better implementation of larger connector hitboxes

This commit is contained in:
itsmattkc
2022-07-27 12:40:27 -07:00
parent 992f3fd3af
commit 183dc8c48e
4 changed files with 21 additions and 19 deletions
+1 -17
View File
@@ -432,23 +432,7 @@ void NodeView::mousePressEvent(QMouseEvent *event)
if (HandPress(event)) return;
// Get the item that the user clicked on, if any
QGraphicsItem* item = nullptr;
{
// Prioritize connectors. I tried overriding boundingRect() and contains() on the connector
// object, but it ended up not working or causing other issues, so this is my hackier solution
const int radius = fontMetrics().height()/2;
QRect connector_rect(event->pos().x()-radius, event->pos().y()-radius, radius*2, radius*2);
QList<QGraphicsItem*> items = this->items(connector_rect);
for (QGraphicsItem *i : items) {
if (dynamic_cast<NodeViewItemConnector*>(i)) {
item = i;
break;
}
}
}
if (!item) {
item = itemAt(event->pos());
}
QGraphicsItem* item = itemAt(event->pos());
if (event->button() == Qt::LeftButton) {
// Sane defaults