[TD]Navigation Styles - context menu handling & std cursors
This commit is contained in:
committed by
WandererFan
parent
60b79e0d72
commit
203b9bb26c
@@ -34,7 +34,8 @@ using namespace TechDrawGui;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
QGVNavStyleRevit::QGVNavStyleRevit()
|
||||
QGVNavStyleRevit::QGVNavStyleRevit(QGVPage *qgvp) :
|
||||
QGVNavStyle(qgvp)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,16 +45,8 @@ QGVNavStyleRevit::~QGVNavStyleRevit()
|
||||
|
||||
void QGVNavStyleRevit::handleMousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
//pan mode 1 - LMB + RMB
|
||||
if (event->buttons() == (Qt::LeftButton & Qt::RightButton)) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//pan mode 2 - MMB
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
startPan(event->pos());
|
||||
event->accept();
|
||||
if (event->button() == Qt::RightButton) {
|
||||
startClick(Qt::RightButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +56,30 @@ void QGVNavStyleRevit::handleMouseMoveEvent(QMouseEvent *event)
|
||||
getViewer()->setBalloonCursorPos(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
//if the mouse moves between press and release, then it isn't a click
|
||||
if (m_clickPending) {
|
||||
stopClick();
|
||||
return;
|
||||
}
|
||||
|
||||
//pan mode 1 - MMB + move
|
||||
if (QGuiApplication::mouseButtons() & Qt::MiddleButton) {
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
} else {
|
||||
startPan(event->pos());
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//pan mode 2 - LMB + RMB + move
|
||||
if (QGuiApplication::mouseButtons() & Qt::LeftButton &&
|
||||
QGuiApplication::mouseButtons() & Qt::RightButton) {
|
||||
if (panningActive) {
|
||||
pan(event->pos());
|
||||
} else {
|
||||
startPan(event->pos());
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
@@ -75,15 +90,39 @@ void QGVNavStyleRevit::handleMouseReleaseEvent(QMouseEvent *event)
|
||||
placeBalloon(event->pos());
|
||||
}
|
||||
|
||||
if (panningActive) {
|
||||
//stop panning if any button release
|
||||
if ( (event->button() == Qt::LeftButton) ||
|
||||
(event->button() == Qt::RightButton) ||
|
||||
(event->button() == Qt::MiddleButton) ){
|
||||
if ((event->button() == Qt::RightButton) &&
|
||||
m_clickPending &&
|
||||
(m_clickButton == Qt::RightButton)) {
|
||||
stopClick();
|
||||
pseudoContextEvent();
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
//stop panning if any button released
|
||||
if ( (event->button() == Qt::LeftButton) ||
|
||||
(event->button() == Qt::RightButton) ||
|
||||
(event->button() == Qt::MiddleButton) ){
|
||||
if (panningActive) {
|
||||
stopPan();
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool QGVNavStyleRevit::allowContextMenu(QContextMenuEvent *event)
|
||||
{
|
||||
// Base::Console().Message("QGVNSRevit::allowContextMenu()\n");
|
||||
if (event->reason() == QContextMenuEvent::Mouse) {
|
||||
//must check for a button combination involving context menu button
|
||||
if (QGuiApplication::mouseButtons() & Qt::LeftButton) {
|
||||
//LMB down - don't allow context menu
|
||||
return false;
|
||||
} else if (m_clickPending) {
|
||||
//context menu request to be handled by button release
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace TechDrawGui
|
||||
|
||||
Reference in New Issue
Block a user