From 1bc204a87f19a9368bfe68705375da891ff45839 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 19 Nov 2009 11:21:05 +0000 Subject: [PATCH] From J.P. Delport, "simple addition to make the scroll wheel work in the example." --- examples/osgviewerWX/osgviewerWX.cpp | 13 +++++++++++++ examples/osgviewerWX/osgviewerWX.h | 1 + 2 files changed, 14 insertions(+) diff --git a/examples/osgviewerWX/osgviewerWX.cpp b/examples/osgviewerWX/osgviewerWX.cpp index 518fbc96a..0a7ac616f 100644 --- a/examples/osgviewerWX/osgviewerWX.cpp +++ b/examples/osgviewerWX/osgviewerWX.cpp @@ -127,6 +127,7 @@ BEGIN_EVENT_TABLE(OSGCanvas, wxGLCanvas) EVT_MIDDLE_UP (OSGCanvas::OnMouseUp) EVT_RIGHT_UP (OSGCanvas::OnMouseUp) EVT_MOTION (OSGCanvas::OnMouseMotion) + EVT_MOUSEWHEEL (OSGCanvas::OnMouseWheel) END_EVENT_TABLE() OSGCanvas::OSGCanvas(wxWindow *parent, wxWindowID id, @@ -229,6 +230,18 @@ void OSGCanvas::OnMouseMotion(wxMouseEvent &event) _graphics_window->getEventQueue()->mouseMotion(event.GetX(), event.GetY()); } +void OSGCanvas::OnMouseWheel(wxMouseEvent &event) +{ + int delta = event.GetWheelRotation() / event.GetWheelDelta() * event.GetLinesPerAction(); + + if (_graphics_window.valid()) { + _graphics_window->getEventQueue()->mouseScroll( + delta>0 ? + osgGA::GUIEventAdapter::SCROLL_UP : + osgGA::GUIEventAdapter::SCROLL_DOWN); + } +} + void OSGCanvas::UseCursor(bool value) { if (value) diff --git a/examples/osgviewerWX/osgviewerWX.h b/examples/osgviewerWX/osgviewerWX.h index 53c06ff90..a79368c9e 100644 --- a/examples/osgviewerWX/osgviewerWX.h +++ b/examples/osgviewerWX/osgviewerWX.h @@ -34,6 +34,7 @@ public: void OnMouseDown(wxMouseEvent &event); void OnMouseUp(wxMouseEvent &event); void OnMouseMotion(wxMouseEvent &event); + void OnMouseWheel(wxMouseEvent &event); void UseCursor(bool value);