Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing GUI Buttons Won't Clear
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
RowanV




PostPosted: Sat May 03, 2014 12:49 pm   Post subject: Turing GUI Buttons Won't Clear

Hey everyone, I am still somewhat new to Turing, and I've been having trouble with my game. I made a series of buttons (a main menu) and one of the buttons on the main menu goes to another set of buttons (a level selector). My problem is that the buttons from the original menu don't go away, they are registered when clicked as opposed to the new buttons, no matter how much I try to get rid of them using commands like dispose, disable, hide, and cls. I made this sample to show you the most basic form of my problem. Help please!
Turing:

import GUI
forward proc Button1
forward proc Button2
forward proc End
body proc End
    put "Done"
end End
body proc Button1
    cls
    var Buttonx : int := GUI.CreateButtonFull (maxx div 2 - 250, maxy div 2 - 50, 500, "Button1", Button2, 100, 's', true)
    loop
        exit when GUI.ProcessEvent
    end loop
    GUI.Dispose (Buttonx)
    GUI.Hide (Buttonx)
    GUI.Disable (Buttonx)
end Button1
body proc Button2
    cls
    var Buttony : int := GUI.CreateButtonFull (maxx div 2 - 250, maxy div 2 - 50, 500, "Button2", End, 100, 's', true)
    loop
        exit when GUI.ProcessEvent
    end loop
end Button2
Button1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat May 03, 2014 2:30 pm   Post subject: Re: Turing GUI Buttons Won't Clear

RowanV @ Sat May 03, 2014 12:49 pm wrote:
I made this sample to show you the most basic form of my problem.

This is the best way to get help with figuring out problems.

Turing:

    loop
        exit when GUI.ProcessEvent
    end loop
    GUI.Dispose (Buttonx)
]
Here, GUI.Dispose is positioned after an infinite loop. The loop will not exit until GUI.Quit is called (See GUI.ProcessEvent), but such is not available in your example. The documentation on GUI.Dispose provides an example that should work.

You might not want to actually use GUI.Quit, as it will disable all ProcessEvent calls. You can exit your loops via your own conditions
Turing:

loop
  if <your condition> then
    % do stuff
  elsif <condition to exit> then
    exit
  elsif GUI.ProcessEvent then
    % handle GUI.Quit
  end if
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ocaber12




PostPosted: Wed Dec 09, 2015 7:33 pm   Post subject: RE:Turing GUI Buttons Won\'t Clear

how do I have multiple buttons on one screen?
Insectoid




PostPosted: Wed Dec 09, 2015 10:59 pm   Post subject: RE:Turing GUI Buttons Won\'t Clear

Just create more than one button. Use GUI.CreateButton twice to get two different buttons.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: