It is currently Sun Aug 20, 2017 5:59 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 4 posts ] 
Author Message
 Post subject: Escape Key doesn't work
PostPosted: Tue Apr 28, 2015 1:04 pm 

Joined: Fri Aug 22, 2014 3:54 pm
Posts: 17
This is not an issue with this particular shader tutorial, but an issue I've had through the entire series so far. For some reason, me pressing the Esc button sometimes will not close the window, any idea on how to fix this? I check for the VK_ESC button to be pressed. It works sometimes, but not others. If I'm in the console and press it, it sometimes works, and sometimes doesn't. If I'm in the window application, it sometimes works and sometimes doesn't. I'm checking for the keypress and exiting with the two methods below. It also refuses to quit sometimes when I press the X on the rendering window, but it will always close when I exit the console with the X button.

Detected in Render window with...
void Game::KeyboardInput(unsigned k, bool p){
   if (k == VK_ESCAPE || k == 0x1b) PostQuitMessage(0);
   std::ostringstream strStream;
   strStream << "Key 0x" << std::hex<<k
      << " is at state " << std::dec << p << std::endl;
   Logger::log(strStream);
}


Detected in console window with...
void Game::ConsoleKeyboardInput(unsigned k, bool p){
   static bool keyPRessed[256] = { 0 };
   if (k < 256)
      keyPRessed[k] = p;

   if (!p){ return;  }

   switch (k){
   case VK_ESCAPE:
      std::cout << "Exiting...\n";
      PostQuitMessage(0);
      PostQuitMessage(0);
      //exit(0);
      break;
   }
}


When pressing escape, I see the text "Exiting..." but it doesn't actually exit. I've been trying to figure this out on my own, but I'm not having any luck. Any ideas?


Offline
 Profile  
 
 Post subject: Re: Escape Key doesn't work
PostPosted: Tue Apr 28, 2015 2:29 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
When PostQuitMessage is called it should be handled by Engine::windowProc() and then inside Engine::start, PeekMessage( &_msg, NULL, 0, 0, PM_REMOVE ) should return ( WM_QUIT == _msg.message ) so that you exit out of the while loop.

you'd need to put some breakpoints in these spots to find out what is going wrong.


Offline
 Profile  
 
 Post subject: Re: Escape Key doesn't work
PostPosted: Wed Apr 29, 2015 7:00 am 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
viewtopic.php?p=2530#p2530


Offline
 Profile  
 
 Post subject: Re: Escape Key doesn't work
PostPosted: Sun May 03, 2015 2:42 am 

Joined: Fri Aug 22, 2014 3:54 pm
Posts: 17
GoryImpaler wrote:
http://www.marek-knows.com/phpBB3/viewtopic.php?p=2530#p2530


That solved it! Thanks for the pointer.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron