From J.P. Delport, "simple addition to make the scroll wheel work in the example."

This commit is contained in:
Robert Osfield 2009-11-19 11:21:05 +00:00
parent ec788e92f2
commit 1bc204a87f
2 changed files with 14 additions and 0 deletions

View File

@ -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)

View File

@ -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);