From 456d0d082b2f7ebba9678bb68e621815f35b6968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 30 Dec 2005 21:02:33 +0000 Subject: [PATCH] We now have mouse wheel support for all views that have scroll bars. Should probably increase the values we got from BScrollBar::GetSteps(), though, as it's a bit slow. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15755 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 42 ++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index d5b29194cf..813631bdf5 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -3642,7 +3642,47 @@ BView::MessageReceived(BMessage *msg) status_t err; if (!msg->HasSpecifiers()) { - BHandler::MessageReceived(msg); + if (msg->what == B_MOUSE_WHEEL_CHANGED) { + float deltaX = 0.0f, deltaY = 0.0f; + + BScrollBar *horizontal = ScrollBar(B_HORIZONTAL); + if (horizontal != NULL) + msg->FindFloat("be:wheel_delta_x", &deltaX); + + BScrollBar *vertical = ScrollBar(B_VERTICAL); + if (vertical != NULL) + msg->FindFloat("be:wheel_delta_y", &deltaY); + + if (deltaX == 0.0f && deltaY == 0.0f) + return; + + float smallStep, largeStep; + if (horizontal != NULL) { + horizontal->GetSteps(&smallStep, &largeStep); + + // pressing the option key scrolls faster + if (modifiers() & B_OPTION_KEY) + deltaX *= largeStep; + else + deltaX *= smallStep; + + horizontal->SetValue(horizontal->Value() + deltaX); + } + + if (vertical != NULL) { + vertical->GetSteps(&smallStep, &largeStep); + + // pressing the option key scrolls faster + if (modifiers() & B_OPTION_KEY) + deltaY *= largeStep; + else + deltaY *= smallStep; + + vertical->SetValue(vertical->Value() + deltaY); + } + } else + BHandler::MessageReceived(msg); + return; }