Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Close Window with the "X" button does not work with while()

Author
Message
Arnaud474
11
Years of Service
User Offline
Joined: 20th Apr 2012
Location:
Posted: 21st Apr 2012 00:47
Here is my problem. I want to make a while() so my text flash every half second. Here is the code.

while(dbReturnKey() != 1)
{
dbCenterText(centerX, centerY, "Press ENTER to start...");
dbWait(500);
dbCLS();
dbWait(500);
}

It skips to the next part of my code when I press "ENTER", but when I press the Red "X" button to close the window it freezes and cannot get the program to close properly.

What I need to know is if there is a function for when you click on the "X".

For exemple : while(dbReturnKey() != 1 || !"FUNCTION FOR CLOSING THE WINDOW")

or

If you have another way of doing the flashing text thingy.

Thanks in advance!
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 21st Apr 2012 06:15
Ok, so the series of commands you are using don't let the program respond to inputs while its "Waiting". So, I would recommend making a boolean var called textup that tells if the text is up or not. Then, wait like 30 refreshes (use a counting var to tell how many refreshes its been) and then reset the counter and invert the state of the text. So, if its up, take it down, if its down put it up(also record that you put it up or took it down for next time around).


Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 21st Apr 2012 10:29 Edited at: 21st Apr 2012 10:31
You could also try:

while(dbReturnKey() != 1 && loopGDK()){
}

LoopGDK at the least checks for the ESCAPE key, but I wouldn't be surprised if it also checked for the windows close button and various other things. Give it a try.

Btw, DeadTomGC's advice about coding delays etc is a better way to code your loop. I'm just suggesting a possible quick fix without having to change your code.

Arnaud474
11
Years of Service
User Offline
Joined: 20th Apr 2012
Location:
Posted: 22nd Apr 2012 19:21
I'll try this out. Thanks for the answers!

Login to post a reply

Server time is: 2024-04-20 06:55:16
Your offset time is: 2024-04-20 06:55:16