Looping with GUIs
Author |
Message |
atrain
|
Posted: 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:
code: | 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
loop
var quitButton : int := GUI.CreateButton (10, 10, 0, "Quit", GUI.Quit)
GUI.SetKeyEventHandler (KeyHandler)
loop
exit when GUI.ProcessEvent
end loop
put "Done!" |
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:
code: |
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
loop
var quitButton : int := GUI.CreateButton (10, 10, 0, "Quit", GUI.Quit)
GUI.SetKeyEventHandler (KeyHandler)
loop
exit when GUI.ProcessEvent
end loop
GUI.Refresh
GUI.Dispose(quitButton)
put "Done!"
end loop |
Any help would be apreciated! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
cycro1234
|
Posted: Wed Feb 16, 2005 9:21 pm Post subject: (No subject) |
|
|
What is the program supposed to do?
Is it suposed to get input from the user? If so, u need a get command. |
|
|
|
|
|
cycro1234
|
Posted: Wed Feb 16, 2005 9:26 pm Post subject: (No 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!" |
|
|
|
|
|
atrain
|
Posted: Wed Feb 16, 2005 9:31 pm Post subject: (No 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... |
|
|
|
|
|
cycro1234
|
Posted: Wed Feb 16, 2005 9:35 pm Post subject: (No 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? |
|
|
|
|
|
atrain
|
Posted: Wed Feb 16, 2005 9:39 pm Post subject: (No 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... |
|
|
|
|
|
atrain
|
Posted: Wed Feb 16, 2005 9:42 pm Post subject: (No 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... |
|
|
|
|
|
cycro1234
|
Posted: Wed Feb 16, 2005 9:55 pm Post subject: (No 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. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
atrain
|
Posted: Wed Feb 16, 2005 9:58 pm Post subject: (No subject) |
|
|
look at my second example - I did use GUI.Refresh, but it still will not work... |
|
|
|
|
|
Bacchus
|
Posted: Wed Feb 16, 2005 10:07 pm Post subject: (No 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 |
|
|
|
|
|
cycro1234
|
|
|
|
|
atrain
|
Posted: Thu Feb 17, 2005 12:05 am Post subject: (No 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... |
|
|
|
|
|
atrain
|
Posted: Thu Feb 17, 2005 12:53 am Post subject: (No 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... |
|
|
|
|
|
|
|