This commit is contained in:
CodingJellyfish 2023-11-12 11:32:04 +08:00 committed by GitHub
parent 1ba1e7e59f
commit bd245e17bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -146,7 +146,7 @@ bool CGUIScrollBar::OnEvent(const SEvent& event)
// thanks to tommi by tommi for another bugfix
// everybody needs a little thanking. hallo niko!;-)
setPos( getPos() +
( (event.MouseInput.Wheel < 0 ? -1 : 1) * SmallStep * (Horizontal ? 1 : -1 ) )
( event.MouseInput.Wheel * SmallStep * (Horizontal ? 1 : -1 ) )
);
SEvent newEvent;

View File

@ -833,14 +833,20 @@ bool CIrrDeviceSDL::run()
break;
case SDL_MOUSEWHEEL:
if (SDL_event.wheel.x > 0 || SDL_event.wheel.x < 0)
break;
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
irrevent.MouseInput.X = MouseX;
irrevent.MouseInput.Y = MouseY;
irrevent.MouseInput.ButtonStates = MouseButtonStates;
irrevent.MouseInput.Wheel = SDL_event.wheel.y > 0 ? 1.0f : -1.0f;
#if SDL_VERSION_ATLEAST(2, 0, 18)
irrevent.MouseInput.Wheel =
SDL_event.wheel.preciseX + SDL_event.wheel.preciseY;
#else
irrevent.MouseInput.Wheel = irr::core::clamp<irr::f32>(
SDL_event.wheel.x + SDL_event.wheel.y, -1.0f, 1.0f);
#endif
postEventFromUser(irrevent);
break;

View File

@ -363,7 +363,7 @@ bool CGUISTKListBox::OnEvent(const SEvent& event)
switch(event.MouseInput.Event)
{
case EMIE_MOUSE_WHEEL:
ScrollBar->setPos(ScrollBar->getPos() + (event.MouseInput.Wheel < 0 ? -1 : 1)*-ItemHeight/2);
ScrollBar->setPos(ScrollBar->getPos() + event.MouseInput.Wheel * -ItemHeight / 2);
return true;
case EMIE_LMOUSE_PRESSED_DOWN: