Jump to content
  • Advertisement
Sign in to follow this  
emforce

toggling buttons and user interface

This topic is 3427 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi guys i was just wondering how i would toggle a bool value off using one key. and also how would i implement a user interface into an app for instance: i have an application which renders simple geometry and i want to add the button which puts on the FPS: counter box. how would i go about doing this?

Share this post


Link to post
Share on other sites
Advertisement
Toggling a value on a key press is straightforward. Just use the windows messaging loop.


bool blarg = false;
//
//
//
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
//If bool is true set to false else set to true
(blarg == true) ? (blarg = false) : (blarg = true);
break;
}
return 0;


Share this post


Link to post
Share on other sites
Quote:
Original post by Downie
(blarg == true) ? (blarg = false) : (blarg = true);
And what, pray tell, is wrong with the following?
blarg = !blarg;

Share this post


Link to post
Share on other sites
Quote:
Original post by CirdanValen

myBool = !myBool;



Lol that would have made more sense. Don't even ask me why I used the other operator cos I couldn't tell you!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!