Computer Science Canada GUI button.... How to do an if GUI button pressed |
Author: | nick4563 [ Mon Jan 17, 2011 7:58 pm ] | ||
Post subject: | GUI button.... How to do an if GUI button pressed | ||
What is it you are trying to achieve? I want to add 1 to the value of i if my GUI Button is pressed What is the problem you are having? Don't know what to do for the if statement Describe what you have tried to solve this problem Not much I'm stumped ![]() Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using 4.1.1 |
Author: | TerranceN [ Mon Jan 17, 2011 8:18 pm ] |
Post subject: | RE:GUI button.... How to do an if GUI button pressed |
Your program will never reach that if statement until GUI.Quit is called. Instead you need to understand how the Turing GUI module works. The loop that has GUI.ProcessEvent in it, will check to see if any buttons are pressed, update them, draw them, etc. The only way it returns true (and therefore exits the loop) is if the GUI has quit. When you press a button, the GUI module calls the procedure you give it when you made the button. The only way to know the button has been pressed is if that procedure has been called. So basically all you have to do, is increment i in your NextQ procedure. |
Author: | nick4563 [ Mon Jan 17, 2011 9:32 pm ] |
Post subject: | RE:GUI button.... How to do an if GUI button pressed |
OK i read the GUI module page and understand what you are saying now thank you my code now works great... Do you have any ideas on how to set restrictions sot hat a string variable can only be ye or no? |
Author: | Tony [ Mon Jan 17, 2011 10:25 pm ] | ||
Post subject: | RE:GUI button.... How to do an if GUI button pressed | ||
|
Author: | nick4563 [ Tue Jan 18, 2011 3:34 pm ] |
Post subject: | RE:GUI button.... How to do an if GUI button pressed |
thanks got it |