Skip to content

Commit e4b75e3

Browse files
authored
Add pollEventsWithImGui (#13)
1 parent e220775 commit e4b75e3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/DearImGui/SDL.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module DearImGui.SDL (
2020
sdl2NewFrame
2121
, sdl2Shutdown
2222
, pollEventWithImGui
23+
, pollEventsWithImGui
2324
)
2425
where
2526

@@ -81,3 +82,12 @@ pollEventWithImGui = liftIO do
8182
[C.exp| void { ImGui_ImplSDL2_ProcessEvent((SDL_Event*) $(void* evPtr')) } |]
8283

8384
pollEvent
85+
86+
-- | Like the SDL2 'pollEvents' function, while also dispatching the events to
87+
-- Dear ImGui. See 'pollEventWithImGui'.
88+
pollEventsWithImGui :: MonadIO m => m [Event]
89+
pollEventsWithImGui = do
90+
e <- pollEventWithImGui
91+
case e of
92+
Nothing -> pure []
93+
Just e' -> ( e' : ) <$> pollEventsWithImGui

0 commit comments

Comments
 (0)