Computer Science Canada Looping with GUIs |
Author: | atrain [ Wed Feb 16, 2005 9:10 pm ] | ||||
Post subject: | Looping with GUIs | ||||
i have a program which is required to loop, but when i have a gui button in it, it does not loop properly: eg:
The above works fine alone, but put it in a loop, and it does not work. I have tryed GUI.Refresh and GUI.Dispose(quitButton), but no worky:
Any help would be apreciated! |
Author: | cycro1234 [ Wed Feb 16, 2005 9:21 pm ] |
Post subject: | |
What is the program supposed to do? Is it suposed to get input from the user? If so, u need a get command. |
Author: | cycro1234 [ Wed Feb 16, 2005 9:26 pm ] |
Post subject: | |
I hope this helps: import GUI procedure KeyHandler (ch : char) if ch = 'Q' or ch = 'q' or ch = 'X' or ch = 'x' then GUI.Quit end if end KeyHandler GUI.SetKeyEventHandler (KeyHandler) var quitButton : int := GUI.CreateButton (10, 10, 0, "Quit", GUI.Quit) loop exit when GUI.ProcessEvent end loop put "Done!" |
Author: | atrain [ Wed Feb 16, 2005 9:31 pm ] |
Post subject: | |
that was the default thing... Try and loop it... see what happens... thats what Im talking about. Ive treid everything that could refresh the gui, but without sucess... |
Author: | cycro1234 [ Wed Feb 16, 2005 9:35 pm ] |
Post subject: | |
So u want it so u can push a button and it says quit, then reset itself and give u the option of pushing quit again? |
Author: | atrain [ Wed Feb 16, 2005 9:39 pm ] |
Post subject: | |
yes... That isn't my acual program, but its the same sort of idea, with animations and stuff... So, if i can manage to get that to loop, i can port it to my program... the GUI buttons and stuff from the begining become useable again, but they are covered with the images in my program, and cls doesnt help... |
Author: | atrain [ Wed Feb 16, 2005 9:42 pm ] |
Post subject: | |
GUI.Quit basicly sets GUI.ProcessEvent on. GUI.Reset will reset it back to off. But it still skips over it afterwards. GUI.Dispose(WigetID) should completely remove the original button, and then it will be redraw when it is called again after looping. But, as you can see, it doesnt work... |
Author: | cycro1234 [ Wed Feb 16, 2005 9:55 pm ] |
Post subject: | |
The problem is the exit when GUI.ProcessEvent. Are you saying that GUI.Refresh resets GUI.ProcessEvent back to false? Because once you push exit, the process event value is true and it does not turn back to false. I tried GUI.Refresh too, and it doesn't seem to reset process event. |
Author: | atrain [ Wed Feb 16, 2005 9:58 pm ] |
Post subject: | |
look at my second example - I did use GUI.Refresh, but it still will not work... |
Author: | Bacchus [ Wed Feb 16, 2005 10:07 pm ] |
Post subject: | |
GUI.Refresh doesnt resent GUI.ProcessEvent, it just refreshes the GUI stuff to the top of the screen(in case something was drawn over top of them). there is a tutorial on reseting GUI.ProcessEvent or you can set a temporary variable to that (var tmp:int:=GUI.ProcessEvent) and exit the gui loop when another variable is set to true (make a proc to set that variable) and so on |
Author: | cycro1234 [ Wed Feb 16, 2005 10:38 pm ] |
Post subject: | |
Ok, well i found the link to the reseting the GUI.ProcessEvent tutorial: http://www.compsci.ca/v2/viewtopic.php?t=2600 If u have Turing 4.05 then go here for a list of new commands. Look up GUI.ResetQuit for more info http://www.compsci.ca/v2/viewtopic.php?t=2996 Hope it helped |
Author: | atrain [ Thu Feb 17, 2005 12:05 am ] |
Post subject: | |
I need to do this on school computers, so this could get anoying if i want to do that, i would have to copy over all the GUI stuff, then change the files in a dir i have wirte acess to... |
Author: | atrain [ Thu Feb 17, 2005 12:53 am ] |
Post subject: | |
figured it out: i had the original go button, then a end button. The go button was always there. You have to press both buttons... ![]() so i did a GUI.Dispose and it works fine... thanx for all your help!!! ill submit the program after i finish it.. program works great... |