I have a window with a GLCanvas and scroll bars, I want the canvas to capture scroll events and forward them to the scroll bars, which are then used to position the 'camera.' So I've done this:
MainWindow::MainWindow(wxWindow* parent,wxWindowID id)
GlCanvas->Connect(ID_GLCANVAS1, wxEVT_MOUSEWHEEL, (wxObjectEventFunction)&MainWindow::onMouseWheel, 0L, this);
void MainWindow::onMouseWheel(wxMouseEvent & event)
if(event.GetWheelAxis() == wxMOUSE_WHEEL_VERTICAL)
std::cerr << "vertical scroll" << std::endl;
std::cerr << "horizontal scroll" << std::endl;
You can't forward wx events to native controls, if you think about it, how would it possible for this to work when the native controls don't have any idea about wx? So it doesn't and never will.
In this particular case you can (relatively) easily translate scroll events to the calls to
ScrollPages() or just
SetScrollPos(). This will allow you to control another window scrolling using the same scrollbar.
Do not forget to call
Skip() in the original handler to let the window being scrolled from actually scrolling too.