Gui: Pass wheel event to viewprovider

=====================================

https://forum.freecadweb.org/viewtopic.php?p=578857#p578857
This commit is contained in:
Abdullah Tahiri
2022-03-13 10:00:17 +01:00
committed by abdullahtahiriyo
parent 33577a087f
commit 85cf3ca514
3 changed files with 23 additions and 3 deletions

View File

@@ -41,6 +41,7 @@
#include <Base/Exception.h>
#include <Base/Matrix.h>
#include "SoMouseWheelEvent.h"
#include "ViewProvider.h"
#include "ActionFunction.h"
#include "Application.h"
@@ -217,7 +218,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
// Therefore, we shall ignore ESC while any mouse button is
// pressed, until this Coin bug is fixed.
if (!press) {
// react only on key release
// react only on key release
// Let first selection mode terminate
Gui::Document* doc = Gui::Application::Instance->activeDocument();
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
@@ -229,7 +230,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
return;
}
}
Gui::TimerFunction* func = new Gui::TimerFunction();
func->setAutoDelete(true);
func->setFunction(boost::bind(&Document::resetEdit, doc));
@@ -258,6 +259,12 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
if (self->mouseButtonPressed(button,press,ev->getPosition(),viewer))
node->setHandled();
}
else if (ev->getTypeId().isDerivedFrom(SoMouseWheelEvent::getClassTypeId())) {
const SoMouseWheelEvent * const event = (const SoMouseWheelEvent *) ev;
if (self->mouseWheelEvent(event->getDelta(), event->getPosition(), viewer))
node->setHandled();
}
// Mouse Movement handling
else if (ev->getTypeId().isDerivedFrom(SoLocation2Event::getClassTypeId())) {
if (self->mouseMove(ev->getPosition(),viewer))
@@ -670,6 +677,14 @@ bool ViewProvider::mouseButtonPressed(int button, bool pressed,
return false;
}
bool ViewProvider::mouseWheelEvent(int delta, const SbVec2s &cursorPos, const View3DInventorViewer* viewer)
{
(void) delta;
(void) cursorPos;
(void) viewer;
return false;
}
void ViewProvider::setupContextMenu(QMenu* menu, QObject* receiver, const char* method)
{
auto vector = getExtensionsDerivedFromType<Gui::ViewProviderExtension>();