1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

More hacking on Widgets.

This commit is contained in:
Andreas Kling 2018-10-11 01:48:09 +02:00
parent aee66e0119
commit f337616741
15 changed files with 135 additions and 19 deletions

View file

@ -12,6 +12,19 @@ EventLoopSDL::~EventLoopSDL()
{
}
static inline MouseButton toMouseButton(byte sdlButton)
{
printf("sdlbutton = %u\n", sdlButton);
if (sdlButton == 1)
return MouseButton::Left;
if (sdlButton == 2)
return MouseButton::Middle;
if (sdlButton == 3)
return MouseButton::Right;
ASSERT_NOT_REACHED();
return MouseButton::None;
}
void EventLoopSDL::waitForEvent()
{
SDL_Event sdlEvent;
@ -30,6 +43,9 @@ void EventLoopSDL::waitForEvent()
case SDL_MOUSEMOTION:
postEvent(&AbstractScreen::the(), make<MouseEvent>(Event::MouseMove, sdlEvent.motion.x, sdlEvent.motion.y));
return;
case SDL_MOUSEBUTTONDOWN:
postEvent(&AbstractScreen::the(), make<MouseEvent>(Event::MouseDown, sdlEvent.button.x, sdlEvent.button.y, toMouseButton(sdlEvent.button.button)));
return;
}
}
}