From f31853d30bfca002dec038169f60d3f89eaa89a1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 13 May 2012 01:27:17 +0200 Subject: [PATCH] mouse wheel works when mouse is over an item --- apps/openmw/mwgui/container.cpp | 12 +++++++++++- apps/openmw/mwgui/container.hpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 8742bf4f7..fd83bddfc 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -38,6 +38,7 @@ void ContainerBase::setWidgets(Widget* containerWidget, ScrollView* itemView) mItemView = itemView; mContainerWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerBase::onContainerClicked); + mContainerWidget->eventMouseWheel += MyGUI::newDelegate(this, &ContainerWindow::onMouseWheel); } ContainerBase::~ContainerBase() @@ -92,6 +93,14 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender) } } +void ContainerBase::onMouseWheel(MyGUI::Widget* _sender, int _rel) +{ + if (mItemView->getViewOffset().left + _rel*0.3 > 0) + mItemView->setViewOffset(MyGUI::IntPoint(0, 0)); + else + mItemView->setViewOffset(MyGUI::IntPoint(mItemView->getViewOffset().left + _rel*0.3, 0)); +} + void ContainerBase::setFilter(ContainerBase::Filter filter) { mFilter = filter; @@ -155,7 +164,8 @@ void ContainerBase::drawItems() backgroundWidget->setUserData(*iter); backgroundWidget->setImageTexture( isMagic ? "textures\\menu_icon_magic.dds" : ""); backgroundWidget->setProperty("ImageCoord", "0 0 42 42"); - backgroundWidget->eventMouseButtonClick += MyGUI::newDelegate(this,&ContainerBase::onSelectedItem); + backgroundWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerBase::onSelectedItem); + backgroundWidget->eventMouseWheel += MyGUI::newDelegate(this, &ContainerBase::onMouseWheel); // image ImageBox* image = backgroundWidget->createWidget("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default); diff --git a/apps/openmw/mwgui/container.hpp b/apps/openmw/mwgui/container.hpp index 7fe04cd48..6bfee1346 100644 --- a/apps/openmw/mwgui/container.hpp +++ b/apps/openmw/mwgui/container.hpp @@ -76,6 +76,7 @@ namespace MWGui void onSelectedItem(MyGUI::Widget* _sender); void onContainerClicked(MyGUI::Widget* _sender); + void onMouseWheel(MyGUI::Widget* _sender, int _rel); void drawItems(); };