Merge pull request #22998 from Rexbas/prevent-showing-context-menu
Navigation: Prevent showing context menu after panning or rubber band selection
This commit is contained in:
@@ -295,10 +295,19 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
// Prevent interrupting rubber-band selection in sketcher
|
||||
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
|
||||
newmode = NavigationStyle::SELECTION;
|
||||
if (!button1down || !button2down) { // Allow canceling rubber-band in sketcher if both button 1 and button 2 are pressed
|
||||
newmode = NavigationStyle::SELECTION;
|
||||
}
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -315,6 +315,13 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -297,6 +297,13 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -1591,6 +1591,14 @@ void NavigationStyle::syncModifierKeys(const SoEvent * const ev)
|
||||
void NavigationStyle::setViewingMode(const ViewerMode newmode)
|
||||
{
|
||||
const ViewerMode oldmode = this->currentmode;
|
||||
|
||||
// Reset flags when changing from IDLE to another mode or if the mode is IDLE and the buttons are released
|
||||
if ((oldmode == IDLE && newmode != IDLE) || (newmode == IDLE && !button1down && !button2down && !button3down)) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode == oldmode) {
|
||||
|
||||
// The rotation center could have been changed even if the mode has not changed
|
||||
@@ -1601,12 +1609,6 @@ void NavigationStyle::setViewingMode(const ViewerMode newmode)
|
||||
return;
|
||||
}
|
||||
|
||||
if (newmode == NavigationStyle::IDLE) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
switch (newmode) {
|
||||
case DRAGGING:
|
||||
// Set up initial projection point for the projector object when
|
||||
|
||||
@@ -273,6 +273,13 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -268,6 +268,13 @@ SbBool OpenSCADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -292,10 +292,19 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
|
||||
// Prevent interrupting rubber-band selection in sketcher
|
||||
if (viewer->isEditing() && curmode == NavigationStyle::SELECTION && newmode != NavigationStyle::IDLE) {
|
||||
newmode = NavigationStyle::SELECTION;
|
||||
if (!button1down || !button2down) { // Allow canceling rubber-band in sketcher if both button 1 and button 2 are pressed
|
||||
newmode = NavigationStyle::SELECTION;
|
||||
}
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -295,6 +295,13 @@ SbBool SolidWorksNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -245,6 +245,13 @@ SbBool TinkerCADNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -272,6 +272,13 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev)
|
||||
processed = false;
|
||||
}
|
||||
|
||||
// Reset flags when newmode is IDLE and the buttons are released
|
||||
if (newmode == IDLE && !button1down && !button2down && !button3down) {
|
||||
hasPanned = false;
|
||||
hasDragged = false;
|
||||
hasZoomed = false;
|
||||
}
|
||||
|
||||
if (newmode != curmode) {
|
||||
this->setViewingMode(newmode);
|
||||
}
|
||||
|
||||
@@ -543,6 +543,7 @@ ViewProviderSketch::ViewProviderSketch()
|
||||
, pObserver(std::make_unique<ViewProviderSketch::ParameterObserver>(*this))
|
||||
, sketchHandler(nullptr)
|
||||
, viewOrientationFactor(1)
|
||||
, blockContextMenu(false)
|
||||
{
|
||||
PartGui::ViewProviderAttachExtension::initExtension(this);
|
||||
PartGui::ViewProviderGridExtension::initExtension(this);
|
||||
@@ -1141,6 +1142,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
||||
case STATUS_SKETCH_UseRubberBand:
|
||||
doBoxSelection(DoubleClick::prvCursorPos, cursorPos, viewer);
|
||||
rubberband->setWorking(false);
|
||||
blockContextMenu = true;
|
||||
|
||||
// use draw(false, false) to avoid solver geometry with outdated construction flags
|
||||
draw(false, false);
|
||||
@@ -1162,6 +1164,8 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
||||
// Right mouse button ****************************************************
|
||||
else if (Button == 2) {
|
||||
if (pressed) {
|
||||
blockContextMenu = false;
|
||||
|
||||
// Do things depending on the mode of the user interaction
|
||||
switch (Mode) {
|
||||
case STATUS_NONE: {
|
||||
@@ -1181,7 +1185,18 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
||||
// Base::Console().log("start dragging, point:%d\n",this->DragPoint);
|
||||
setSketchMode(STATUS_SELECT_Constraint);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STATUS_SKETCH_UseRubberBand:
|
||||
// Cancel rubberband
|
||||
rubberband->setWorking(false);
|
||||
blockContextMenu = true;
|
||||
|
||||
// a redraw is required in order to clear the rubberband
|
||||
draw(true, false);
|
||||
const_cast<Gui::View3DInventorViewer*>(viewer)->redraw();
|
||||
setSketchMode(STATUS_NONE);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -3714,6 +3729,8 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo
|
||||
cameraSensor.setData(camSensorData);
|
||||
cameraSensor.setDeleteCallback(&ViewProviderSketch::camSensDeleteCB, camSensorData);
|
||||
cameraSensor.attach(viewer->getCamera());
|
||||
|
||||
blockContextMenu = false;
|
||||
}
|
||||
|
||||
void ViewProviderSketch::unsetEditViewer(Gui::View3DInventorViewer* viewer)
|
||||
@@ -3727,6 +3744,8 @@ void ViewProviderSketch::unsetEditViewer(Gui::View3DInventorViewer* viewer)
|
||||
viewer->removeGraphicsItem(rubberband.get());
|
||||
viewer->setEditing(false);
|
||||
viewer->setSelectionEnabled(true);
|
||||
|
||||
blockContextMenu = false;
|
||||
}
|
||||
|
||||
void ViewProviderSketch::camSensDeleteCB(void* data, SoSensor *s)
|
||||
@@ -4365,6 +4384,8 @@ bool ViewProviderSketch::isInEditMode() const
|
||||
}
|
||||
void ViewProviderSketch::generateContextMenu()
|
||||
{
|
||||
if (blockContextMenu) return;
|
||||
|
||||
int selectedEdges = 0;
|
||||
int selectedLines = 0;
|
||||
int selectedConics = 0;
|
||||
|
||||
@@ -991,6 +991,8 @@ private:
|
||||
|
||||
SoNodeSensor cameraSensor;
|
||||
int viewOrientationFactor; // stores if sketch viewed from front or back
|
||||
|
||||
bool blockContextMenu;
|
||||
};
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
Reference in New Issue
Block a user