mirror of
				https://github.com/Drezil/dear-imgui.hs.git
				synced 2025-11-03 22:51:07 +01:00 
			
		
		
		
	Fix event handling in demo
This commit is contained in:
		
							
								
								
									
										22
									
								
								Main.hs
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								Main.hs
									
									
									
									
									
								
							@@ -30,7 +30,7 @@ main = do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
loop :: Window -> IORef Bool -> IO ()
 | 
					loop :: Window -> IORef Bool -> IO ()
 | 
				
			||||||
loop w checked = do
 | 
					loop w checked = do
 | 
				
			||||||
  ev <- pollEventWithImGui
 | 
					  quit <- pollEvents
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  openGL2NewFrame
 | 
					  openGL2NewFrame
 | 
				
			||||||
  sdl2NewFrame w
 | 
					  sdl2NewFrame w
 | 
				
			||||||
@@ -85,11 +85,21 @@ loop w checked = do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  glSwapWindow w
 | 
					  glSwapWindow w
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case ev of
 | 
					  if quit then return () else loop w checked
 | 
				
			||||||
    Nothing -> loop w checked
 | 
					
 | 
				
			||||||
    Just Event{ eventPayload } -> case eventPayload of
 | 
					  where
 | 
				
			||||||
      QuitEvent -> return ()
 | 
					
 | 
				
			||||||
      _         -> loop w checked
 | 
					    pollEvents = do
 | 
				
			||||||
 | 
					      ev <- pollEventWithImGui
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      case ev of
 | 
				
			||||||
 | 
					        Nothing -> return False
 | 
				
			||||||
 | 
					        Just Event{ eventPayload } -> do
 | 
				
			||||||
 | 
					          let isQuit = case eventPayload of
 | 
				
			||||||
 | 
					                QuitEvent -> True
 | 
				
			||||||
 | 
					                _         -> False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          (isQuit ||) <$> pollEvents
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
whenTrue :: IO () -> Bool -> IO ()
 | 
					whenTrue :: IO () -> Bool -> IO ()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user