We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b0ef6a4 commit d41a494Copy full SHA for d41a494
sdlpp.hpp
@@ -490,7 +490,10 @@ namespace sdl
490
inline SDL_Event* get() {
491
return &e;
492
}
493
-
+ void setCallback(const std::function<bool(SDL_Event)>& callback_)
494
+ {
495
+ callback = callback_;
496
+ }
497
bool poll()
498
{
499
if (SDL_PollEvent(&e))
@@ -563,8 +566,18 @@ namespace sdl
563
566
#undef EVENT
564
567
private:
565
568
SDL_Event e;
569
+ std::function<bool(SDL_Event)> callback;
570
+
571
void handleEvent()
572
573
+ if (callback)
574
575
+ if (callback(e))
576
577
+ //consider handled
578
+ return;
579
580
581
switch (e.type)
582
583
#define EVENT(x, y, z) \
0 commit comments