tdev
03-06-2008 09:43:42
This patch enables the QuickGUIScrollPane to receive and act on Mouse Wheel events. So you can for example scroll with the mouse wheel in the ComboBox:
i hope i added it at the right location
the vertical scrollbar should also get those handlers one day.
also, do not forget to inject mouse wheel changes:
there is a visual artifact when you scroll: the highlight get not updated. I tried to solve that by back propagating the wheel event, but no luck so far
Index: QuickGUIScrollPane.cpp
===================================================================
--- QuickGUIScrollPane.cpp (revision 1172)
+++ QuickGUIScrollPane.cpp (working copy)
@@ -139,6 +139,7 @@
mManagedWidgets.insert(w);
w->addEventHandler(EVENT_MOUSE_BUTTON_DOWN,&ScrollPane::onChildClicked,this);
+ w->addEventHandler(EVENT_MOUSE_WHEEL,&ScrollPane::onMouseWheel,this);
w->addEventHandler(EVENT_POSITION_CHANGED,&ScrollPane::onChildPositionChanged,this);
w->addEventHandler(EVENT_SIZE_CHANGED,&ScrollPane::onChildSizeChanged,this);
@@ -198,6 +199,16 @@
scrollIntoView(dynamic_cast<const WidgetEventArgs&>(args).widget);
}
+ void ScrollPane::onMouseWheel(const EventArgs& args)
+ {
+ MouseEventArgs argsm = dynamic_cast<const MouseEventArgs&>(args);
+ if(argsm.wheelChange > 0 && mRightBar && mRightBar->isVisible())
+ mRightBar->scrollUpSmall();
+ else if(argsm.wheelChange < 0 && mRightBar && mRightBar->isVisible())
+ mRightBar->scrollDownSmall();
+ }
+
void ScrollPane::onChildPositionChanged(const EventArgs& args)
{
Widget* w = dynamic_cast<const WidgetEventArgs&>(args).widget;
Index: QuickGUIScrollPane.h
===================================================================
--- QuickGUIScrollPane.h (revision 1172)
+++ QuickGUIScrollPane.h (working copy)
@@ -95,7 +95,8 @@
void onParentSizeChanged(const EventArgs& args);
void onHorizontalScroll(const EventArgs& args);
void onVerticalScroll(const EventArgs& args);
-
+ void onMouseWheel(const EventArgs& args);
+
void _showHScrollBars();
void _showVScrollBars();
void _syncBarWithParentDimensions();
i hope i added it at the right location

the vertical scrollbar should also get those handlers one day.
also, do not forget to inject mouse wheel changes:
bool myClass::mouseMoved(const OIS::MouseEvent &arg)
{
mGUIManager->injectMouseMove(arg.state.X.rel, arg.state.Y.rel);
if(arg.state.Z.rel != 0)
mGUIManager->injectMouseWheelChange(arg.state.Z.rel);
return true;
}
there is a visual artifact when you scroll: the highlight get not updated. I tried to solve that by back propagating the wheel event, but no luck so far
