Computer Science Canada [Tutorial] Reseting GUI.ProcessEvent |
Author: | Ashkan [ Fri Dec 26, 2003 2:48 am ] | ||
Post subject: | [Tutorial] Reseting GUI.ProcessEvent | ||
Hey Everyone, Well recently i faced a problem with reseting the GUI.ProcessEvent which as you might know, whenever you press the Quit button you can no longer use that GUI.ProcessEvent in your program. Well i came here and read some of the old posts regarding this topic but non of them really suggested the straight forward answer to it. They mostly suggested that you can use an if statement and that might work for some but for some really complicated ones they dont really work.. so i worked on it and finally i figured out a way to get around this that i want to share with you. Information regarding GUI.ProcessEvent : GUI.ProcessEvent is a function which is predefined in Turing and the function returns the boolean value Ture or Fals. Well by calling this inside a loop you basically allow the program to wait for the user to finish using the GUI structure as it is still set to false, however after they pressed the Quit button the GUI.ProcessEvent will be set to True and it will then exit and the user is not longer able to make changes to GUI structure of the program. Question: Do you want to use the GUI.ProcessEvent more than one time in your program? Do you want to allow the user to be able to use the GUI structure as long as he wants? Solution: 1. Go to your Turing Library of predefined modules and you will find the "%Support/lib/GUIclass". 2. Open the Directory and open the file called "WidgetModule.tu" 3. Simply go the Export list and add the word "quitting" at the end. Details: inside the WidgetModule.tu there is a function called ProcessEvent as follow: Quote: % Process a single event
function ProcessEvent : boolean const activeWindow : int := Window.GetActive theEventTime := Time.Elapsed CheckForDifferentBlinkingTextField if CheckForEvent (activeWindow) then result quitting else for count : 1 .. WidgetGlobals.numWindows if WidgetGlobals.window (count).windowID not= activeWindow then if CheckForEvent (WidgetGlobals.window (count).windowID) then result quitting end if end if end for end if As you might notice the result of the function is "quitting" however it is not in the exported list of the module and thats the reason that you have to add it. ATTENTION: *Doing this you are changing one of the predefined modules and so i strongly recommend you to make a BACK UP of the WidgetModule.tu file in advance. *However you are not really making a big change in it, you are just exporting something Extra there. 4. Open your program and import the "WidgetModule.tu" import GUI in "%oot/lib/GUI", WidgetModule in "C:\\Program Files\\Turing\\Support\\Lib\\GUIClass\\WidgetModule.tu" *Address Above is just an example. you might have to change yours. 5. Now in order to set it false after it has been set to true because the user have proessed the Quit Button , add the following code after it.. Quote: WidgetModule.quitting := false 6. Done 7. =) Example: If you notice there is a program for check box in turing reference that is :
In order to be able to use the program without allowing it to end i made the following changes: Quote: import GUI in "%oot/lib/GUI", WidgetModule in "C:\\Program Files\\Turing\\Support\\Lib\\GUIClass\\WidgetModule.tu" procedure DoNothing (status : boolean) end DoNothing View.Set ("graphics:600;500,nobuttonbar") var cb1 : int := GUI.CreateCheckBox (10, 10, "Check Box 1", DoNothing) var cb2 : int := GUI.CreateCheckBoxFull (200, 10, "Check Box 2", DoNothing, GUI.RIGHT, '2') loop var quitBtn : int := GUI.CreateButton (230, 10, 0, "Quit", GUI.Quit) loop exit when GUI.ProcessEvent end loop var cb1Status : boolean := GUI.GetCheckBox (cb1) var cb2Status : boolean := GUI.GetCheckBox (cb2) if cb1Status then put "Check box 1: filled" else put "Check box 1: empty" end if if cb2Status then put "Check box 2: filled" else put "Check box 2: empty" end if WidgetModule.quitting := false end loop *Change the address accordingly. Works for me. I hope it helps you all. |
Author: | Ashkan [ Fri Dec 26, 2003 2:52 am ] |
Post subject: | Edit |
hey any moderator wants to edit my post cuz althoughh i used the code tag but it didnt work in some parts .. so you might wanna fix that to make it look better .. |
Author: | Tony [ Fri Dec 26, 2003 3:06 am ] |
Post subject: | |
wow, this looks messed... I notices weird stuff is happening when code tag is used more then once I'll talk to dan |
Author: | Homer_simpson [ Sun Dec 28, 2003 2:08 am ] |
Post subject: | |
ashkan man.... by any chance are u persian? |
Author: | Tony [ Sun Dec 28, 2003 1:27 pm ] |
Post subject: | |
score! replacing extra code tags with quote, solves the alignment problems Though it's still messed... I donno whats wrong, but it looks like dan is back in town, so we'll see. Also - its a very nice tutorial, have some+Bits |
Author: | Ashkan [ Mon Dec 29, 2003 3:39 pm ] |
Post subject: | hey y'all |
Hey Homer Simpson, ya am persian and i speak persian fluently cuz i lived in iran for 10 years... hey tony and Dan thanx for editing the interface of the tutorial and thanx for the bits... however whats this whole thing about bits? llllllollll =) |
Author: | Mazer [ Mon Dec 29, 2003 3:45 pm ] |
Post subject: | |
"what are bits"? "what are bits"?!!!?!?! only the single most important thing known to man! (seriously, who needs water anyways?) here's a link to show you just how important bits are: http://www.compsci.ca/v2/viewtopic.php?t=2478 |
Author: | Homer_simpson [ Mon Dec 29, 2003 8:43 pm ] |
Post subject: | |
nice man... u'd be the first persian to join after me... +chandta bit =Þ |
Author: | Ashkan [ Mon Dec 29, 2003 11:00 pm ] |
Post subject: | Halo |
hey homer, nice to meet ya man, merci for bits Am gonna post some of my programs for ya guys, am not into makin games really, mostly dealin with databases and programs.. =P |
Author: | shorthair [ Sat Jan 17, 2004 6:34 pm ] |
Post subject: | |
THIS IS NOW OBSELITE ( cant spell) there is a new command in turing to reset it , no need for extra code just get hte turing 4.0.5 update and your set , raed the help for the 30 + new commands |